C
Chris Forone
hello group,
cant understand the following:
Scene* Scene::sole(0); // in Scene.cpp
class Scene // singleton in Scene.h
{
public:
static Scene* Get()
{
//return sole ? sole : new (std::nothrow) Scene;
return sole; // for testing purposes only
}
int Print(void) // normaly only with valid objects?!
{
return reinterpret_cast<unsigned int>(sole);
// other values also possible (return 10
}
protected:
Scene();
~Scene();
private:
static Scene* sole;
};
int main(void)
{
std::cout << Scene::Get() << std::endl;
std::cout << Scene::Get()->Print() << std::endl;
}
returns
0
0
non static func Print is called by nullpointer?! have gcc 4.1 and linux os.
thanks for your answers
sincerely yours
chris
cant understand the following:
Scene* Scene::sole(0); // in Scene.cpp
class Scene // singleton in Scene.h
{
public:
static Scene* Get()
{
//return sole ? sole : new (std::nothrow) Scene;
return sole; // for testing purposes only
}
int Print(void) // normaly only with valid objects?!
{
return reinterpret_cast<unsigned int>(sole);
// other values also possible (return 10
}
protected:
Scene();
~Scene();
private:
static Scene* sole;
};
int main(void)
{
std::cout << Scene::Get() << std::endl;
std::cout << Scene::Get()->Print() << std::endl;
}
returns
0
0
non static func Print is called by nullpointer?! have gcc 4.1 and linux os.
thanks for your answers
sincerely yours
chris