J
Joost Kraaijeveld
GCC 3.3.1 allows the following code, Borland C++ 6 gives an error. I have
looked in the standard but could not find the answer. Should this code
compile, given that the private destructor (and constructor but there
Borland does not give an error) is called in the public static function:
class Object
{
public:
static Object& getObject()
{
static Object o;
return o;
}
private:
Object(){}
~Object(){}
};
int main()
{
Object& o = Object::getObject();
return 0;
}
TIA
Joost
looked in the standard but could not find the answer. Should this code
compile, given that the private destructor (and constructor but there
Borland does not give an error) is called in the public static function:
class Object
{
public:
static Object& getObject()
{
static Object o;
return o;
}
private:
Object(){}
~Object(){}
};
int main()
{
Object& o = Object::getObject();
return 0;
}
TIA
Joost