D
Damien
Hi all,
I'm using a pretty standard C++ Singleton class, as below:
template <typename T>
class Singleton
{
public:
static T* Instance()
{
static T instance_;
return &instance_;
}
private:
Singleton(); // ctor hidden
~Singleton(); // dtor hidden
Singleton(Singleton const&); // copy ctor hidden
Singleton& operator=(Singleton const&); // assign op hidden
};
Trying to use it on something really simple is giving me headaches:
class DoIt
{
public:
DoIt(){}
~DoIt(){}
void DoSomething(){}
};
int main()
{
DoIt* doit = Singleton<DoIt>::Instance();
doit->DoSomething();
}
I get the compiler error "error: expected constructor, destructor, or
type conversion before '->' token" on the doit->DoSomething(); line. I
can't see how doit can be name-dependent because there's no typedef'ing
associated with it inside the Singleton, unless the static has
something to do with it. Anyone got any ideas?
Damien
I'm using a pretty standard C++ Singleton class, as below:
template <typename T>
class Singleton
{
public:
static T* Instance()
{
static T instance_;
return &instance_;
}
private:
Singleton(); // ctor hidden
~Singleton(); // dtor hidden
Singleton(Singleton const&); // copy ctor hidden
Singleton& operator=(Singleton const&); // assign op hidden
};
Trying to use it on something really simple is giving me headaches:
class DoIt
{
public:
DoIt(){}
~DoIt(){}
void DoSomething(){}
};
int main()
{
DoIt* doit = Singleton<DoIt>::Instance();
doit->DoSomething();
}
I get the compiler error "error: expected constructor, destructor, or
type conversion before '->' token" on the doit->DoSomething(); line. I
can't see how doit can be name-dependent because there's no typedef'ing
associated with it inside the Singleton, unless the static has
something to do with it. Anyone got any ideas?
Damien