decleration problem

Ok so i get an error that says that the base class isnt defined if i move client down . How do i get around this ?

1
2
3
4
5
6
7
8
9
10
11
class base ; 

class client 
{
   public : .......
   private  : 
              base * ptr ; 
}

class base : public client 
{......}
Last edited on
The code above should work, which problem does it have?
You can't inherit class from another that is not fully described. That is because the compiler must have infomation of the base class' size, i.e. its member variables.

Also, this looks like you're trying to do things inside out. Base class (in your code named "client") should not request services of the deriving class (in your code named "base").

You should design your classes so that the requests go from "top to bottom", since the deriving class has all the non-private information of its base classes and not the other way round.
your code should work, but you might need to add ";" at end of the definitions.
my base class is a virtual class....iam using dynamic binding and most of my functions in my base class are virtual functions...
So what's the problem?
it doesnt compile. It says that the base class isnt defined.
Last edited on
Place the class base in the code before client. Or is there a reason you can't do that?
Topic archived. No new replies allowed.