Trying to access a member variable before its defined?

Ok, so I have a code in which there are 2 separate classes, that have two similar functions that react with each other in a similar way, but the first class's function seems to not want to work because it uses variables from the second class, which hasnt been defined yet. Any thoughts on how to remedy this problem?
closed account (zb0S216C)
The simple rule is that identifiers have to be declared before they are used. Have you tried forward declaring the class?

Wazzak
you mean like:

class B;

class A
{
stuff;
}

class B
{
stuff;
}

that?

yeah, i tried that and it still doesnt work. Im not entirely sure thats the problem though, but I think it is.
closed account (zb0S216C)
One data object cannot refer to another data object unless it is declared first. B's members must be known beforehand before A's members refer to them. Forward declaring B, as I first assumed, will not solve your problem. What you're asking cannot be done.

Wazzak
Oh hey, I got it to work! :D
I put the definition of the function that used the variable after the definition of the class it got its variable from
Topic archived. No new replies allowed.