Papers/programming

What is the difference between singleton and static class?

tomato13 2013. 7. 16. 09:13

What is the difference between singleton and static class?

These are just my opinion. 

1. You can use an interface class. In other words, your singleton class can implement interface functions.

2. As you know, memory area is different. A object is stored in heap area and static class is placed in stack. For memory optimization, the singleton way could be useful. 

3. In a static class, you can set member variables at any time. But in a singleton way, you can set the values only after creating an instance. So, the restriction of singleton way could be useful. 


'Papers > programming' 카테고리의 다른 글

void pointer  (0) 2013.11.21
constructor & destructor calling in inheritance  (0) 2013.11.19
이차원 배열선언  (0) 2013.05.17
union vs. struct  (0) 2010.03.31
friend class  (0) 2010.02.25