Sign in to follow this  
Tasche

static pointer in subclass not getting resolved?

Recommended Posts

if i try to do something like this, it gets compiled allready, but the linker bugs me about pB not being resolved ... ???
what im trying to do is store a pointer to b which is known in all instances of B, especially in b itself!

[code]
class A {
class B {
public:
static B* pB;
}
B b[2];
void f();
}

A::B* A::B::pB = NULL;

A::f() {
B::pB = b;
}
[/code]

Share this post


Link to post
Share on other sites
Your code doesn't compile, and when fixed to compile, it does link. Post the actual code that's giving you the problems.

Share this post


Link to post
Share on other sites
never mind, i already rewrote that part avoiding the use of a static pointer alltogether, but still thanks for the trouble!
(btw what needed to be fixed in the sample code above?)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this