-
March 4th, 2012, 07:16 AM
#1
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
-
March 4th, 2012, 07:32 AM
#2
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.
-
March 4th, 2012, 07:38 AM
#3
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|