-
Static call problems
Code:
class A
{
std::map<std::string, Unit*> aMap;
class B
{
void doSomething()
{
callA();
}
};
void callA()
{
aMap.find()....
}
};
this code snippet results in "A non-static member reference must be made relative to a specific object"
When I make callA() static, this error goes away, but there is problem with aMap.
Sorry, I can't translate the message because the IDE is in my language.
So please help me out.
Thanks
Jack
-
Re: Static call problems
The problem is that class B hasn't got a clue which object A that is suppossed to receive the callA call. Pass that information to B when you create it.
-
Re: Static call problems
S_M_A
I pass the object pointer to B, and it is working like a charm. Thanks a lot
Jack