Click here to Skip to main content
15,887,812 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralGet Client Area Excluding Scroll Bar Pin
AmbiguousName5-Jul-12 19:30
AmbiguousName5-Jul-12 19:30 
GeneralRe: Get Client Area Excluding Scroll Bar Pin
Jochen Arndt5-Jul-12 21:32
professionalJochen Arndt5-Jul-12 21:32 
QuestionOne instance of object Pin
_Flaviu5-Jul-12 7:17
_Flaviu5-Jul-12 7:17 
AnswerRe: One instance of object Pin
David Crow5-Jul-12 7:22
David Crow5-Jul-12 7:22 
AnswerRe: One instance of object Pin
fat_boy5-Jul-12 8:13
fat_boy5-Jul-12 8:13 
GeneralRe: One instance of object Pin
_Flaviu5-Jul-12 20:07
_Flaviu5-Jul-12 20:07 
GeneralRe: One instance of object Pin
fat_boy5-Jul-12 21:26
fat_boy5-Jul-12 21:26 
AnswerRe: One instance of object Pin
Stefan_Lang5-Jul-12 22:35
Stefan_Lang5-Jul-12 22:35 
In header file:
C++
class myUniqueClass {
private:
   myUniqueClass();                        // default constructor is private!
   myUniqueClass(const myUniqueClass&);    // copy constructor is private, too!
   static myUniqueClass* myUniqueInstance;
public:
   static myUniqueClass* getInstance();
   // put the real functionality below
   // ...
};

In cpp file:
C++
myUniqueClass* myUniqueClass::myUniqueInstance = 0;
myUniqueClass::getInstance() {
   if (myUniqueInstance == 0) {
      myUniqueInstance = new myUniqueClass;
   }
   return myUniqueInstance;
}

Explanation:
The two private constructors prevent the uncontrolled creation of a new instance, or the copying of the one, valid instance. The getInstance function creates the one instance if necessary: as a member function it can use the private constructor.
GeneralRe: One instance of object Pin
_Flaviu5-Jul-12 23:08
_Flaviu5-Jul-12 23:08 
GeneralRe: One instance of object Pin
fat_boy6-Jul-12 0:14
fat_boy6-Jul-12 0:14 
GeneralRe: One instance of object Pin
_Flaviu6-Jul-12 0:39
_Flaviu6-Jul-12 0:39 
GeneralRe: One instance of object Pin
fat_boy6-Jul-12 1:31
fat_boy6-Jul-12 1:31 
GeneralRe: One instance of object Pin
Stefan_Lang6-Jul-12 5:33
Stefan_Lang6-Jul-12 5:33 
AnswerRe: One instance of object Pin
Luc Pattyn6-Jul-12 0:47
sitebuilderLuc Pattyn6-Jul-12 0:47 
GeneralRe: One instance of object Pin
fat_boy6-Jul-12 1:30
fat_boy6-Jul-12 1:30 
GeneralRe: One instance of object Pin
Stefan_Lang6-Jul-12 1:58
Stefan_Lang6-Jul-12 1:58 
QuestionFloating CSplitterWnd - can it be "easily" done? Pin
Vaclav_5-Jul-12 5:41
Vaclav_5-Jul-12 5:41 
AnswerRe: Floating CSplitterWnd - can it be "easily" done? Pin
Richard MacCutchan5-Jul-12 6:03
mveRichard MacCutchan5-Jul-12 6:03 
GeneralRe: Floating CSplitterWnd - can it be "easily" done? Pin
Vaclav_5-Jul-12 7:22
Vaclav_5-Jul-12 7:22 
GeneralRe: Floating CSplitterWnd - can it be "easily" done? Pin
Richard MacCutchan5-Jul-12 22:23
mveRichard MacCutchan5-Jul-12 22:23 
GeneralIs it a good idea to make VC++ as my programming career language? Pin
Falconapollo5-Jul-12 3:54
Falconapollo5-Jul-12 3:54 
AnswerRe: Is it a good idea to make VC++ as my programming career language? Pin
Richard MacCutchan5-Jul-12 4:10
mveRichard MacCutchan5-Jul-12 4:10 
GeneralRe: Is it a good idea to make VC++ as my programming career language? Pin
Falconapollo5-Jul-12 4:46
Falconapollo5-Jul-12 4:46 
AnswerRe: Is it a good idea to make VC++ as my programming career language? Pin
jschell5-Jul-12 5:57
jschell5-Jul-12 5:57 
GeneralRe: Is it a good idea to make VC++ as my programming career language? Pin
Falconapollo5-Jul-12 14:32
Falconapollo5-Jul-12 14:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.