S
Sarath
I've to write a single instance class. there are different methods to
control the single instance of a program. I've tried the following
method
class CSingleton
{
public:
CSingleton& GetInstance(){ static CSingleton s; return s; }
private:
CSingleton(){}
~CSingleton(){}
}
The above code failed to compile in Visual C++ 6.0 but compiled in
Visual C++ 7.1 and Visual C++ Express 2008. CRT (in microsoft concept)
calling the destructor of the class. So that Visual C++ 6.0
compilation error (Failed to access destructor) is correct according
to the concept.
I also tried in Dev C++. It was successful but didn't call the dtor of
the class. Which implementation is correct according to the standard.
Sorry if off-topic to the forum
control the single instance of a program. I've tried the following
method
class CSingleton
{
public:
CSingleton& GetInstance(){ static CSingleton s; return s; }
private:
CSingleton(){}
~CSingleton(){}
}
The above code failed to compile in Visual C++ 6.0 but compiled in
Visual C++ 7.1 and Visual C++ Express 2008. CRT (in microsoft concept)
calling the destructor of the class. So that Visual C++ 6.0
compilation error (Failed to access destructor) is correct according
to the concept.
I also tried in Dev C++. It was successful but didn't call the dtor of
the class. Which implementation is correct according to the standard.
Sorry if off-topic to the forum