decleration problem

Jul 11, 2010 at 6:03am
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 Jul 11, 2010 at 6:04am
Jul 11, 2010 at 6:24am
The code above should work, which problem does it have?
Jul 11, 2010 at 12:14pm
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.
Jul 11, 2010 at 3:04pm
your code should work, but you might need to add ";" at end of the definitions.
Jul 11, 2010 at 10:21pm
my base class is a virtual class....iam using dynamic binding and most of my functions in my base class are virtual functions...
Jul 12, 2010 at 10:50am
So what's the problem?
Jul 12, 2010 at 5:32pm
it doesnt compile. It says that the base class isnt defined.
Last edited on Jul 12, 2010 at 5:32pm
Jul 13, 2010 at 6:52am
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.