Click here to Skip to main content
15,900,258 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Save C++ Object to XML / Load XML data to C++ [modified] Pin
Rudy10229-May-06 19:45
Rudy10229-May-06 19:45 
GeneralRe: Save C++ Object to XML / Load XML data to C++ [modified] Pin
toxcct29-May-06 22:01
toxcct29-May-06 22:01 
GeneralRe: Save C++ Object to XML / Load XML data to C++ [modified] Pin
Rudy10230-May-06 3:45
Rudy10230-May-06 3:45 
QuestionMapi library error Pin
Javielgrande29-May-06 9:14
Javielgrande29-May-06 9:14 
QuestionSingletone Design Pattern Pin
knoxplusplus29-May-06 7:54
knoxplusplus29-May-06 7:54 
AnswerRe: Singletone Design Pattern Pin
Cedric Moonen29-May-06 8:16
Cedric Moonen29-May-06 8:16 
AnswerRe: Singletone Design Pattern Pin
G Haranadh29-May-06 18:15
G Haranadh29-May-06 18:15 
GeneralRe: Singletone Design Pattern Pin
BadKarma29-May-06 20:32
BadKarma29-May-06 20:32 
Hi,

this class isn't really a singleton, because you can make more than one instances of it.
You need to change the modifier of the constructor from public to at least protected.
This way one is forced to use the instance function.
class my_singleton
{
private:
 std::string my_string;
 my_singleton() : my_string("foo bar bash") {}

public:
 static my_singleton &instance()
 {
  static my_singleton global_instance;
  return global_instance;
 }
 
 std::string get_string() { return my_string; }
};
...
cout << my_singleton::instance().get_string() << endl;




codito ergo sum
GeneralRe: Singletone Design Pattern Pin
G Haranadh29-May-06 22:47
G Haranadh29-May-06 22:47 
GeneralRe: Singletone Design Pattern Pin
knoxplusplus30-May-06 7:36
knoxplusplus30-May-06 7:36 
GeneralRe: Singletone Design Pattern Pin
G Haranadh30-May-06 7:45
G Haranadh30-May-06 7:45 
QuestionCImage linker problems. Please help! Pin
Rostfrei29-May-06 7:53
Rostfrei29-May-06 7:53 
AnswerRe: CImage linker problems. Please help! Pin
Chris Losinger29-May-06 8:21
professionalChris Losinger29-May-06 8:21 
GeneralRe: CImage linker problems. Please help! Pin
Rostfrei29-May-06 10:45
Rostfrei29-May-06 10:45 
GeneralRe: CImage linker problems. Please help! Pin
G Haranadh29-May-06 18:56
G Haranadh29-May-06 18:56 
QuestionVisual C++ COM Wrapper .NET and VB6 Pin
Dave_Roach29-May-06 6:08
Dave_Roach29-May-06 6:08 
AnswerRe: Visual C++ COM Wrapper .NET and VB6 Pin
Milton Karimbekallil29-May-06 6:46
Milton Karimbekallil29-May-06 6:46 
GeneralRe: Visual C++ COM Wrapper .NET and VB6 Pin
Dave_Roach29-May-06 6:53
Dave_Roach29-May-06 6:53 
QuestionData Accessing from a flexgrid control Pin
radhika2829-May-06 4:39
radhika2829-May-06 4:39 
QuestionCSpinButtonCtrl (int) stops at 16960 Pin
evermood29-May-06 4:23
evermood29-May-06 4:23 
AnswerRe: CSpinButtonCtrl (int) stops at 16960 Pin
Chris Losinger29-May-06 5:56
professionalChris Losinger29-May-06 5:56 
GeneralRe: CSpinButtonCtrl (int) stops at 16960 Pin
evermood29-May-06 6:58
evermood29-May-06 6:58 
GeneralRe: CSpinButtonCtrl (int) stops at 16960 Pin
Chris Losinger29-May-06 8:18
professionalChris Losinger29-May-06 8:18 
GeneralRe: CSpinButtonCtrl (int) stops at 16960 Pin
evermood29-May-06 23:12
evermood29-May-06 23:12 
GeneralRe: CSpinButtonCtrl (int) stops at 16960 Pin
Michael Dunn29-May-06 9:26
sitebuilderMichael Dunn29-May-06 9:26 

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.