a derived class inherits all members of the base class, that is what the book says, right? i want to make a derived class that has only some of the members of the base class, and some of its own members and functions, is it ok to do it like this? or shall i get error msgs. i dont like error msgs at all !

nemo

you can't. Like the book says, derived class inherits ALL members of the base class. But, what you can do is make members of the base class not accessible to members of derived class by making base class members private. In the code below, class derived cannot access variable x in class base.

class base
{
...
private:
   int x;
}

class derived : public base
{
...
};

hey thanks , simple solution!! i tried another way and it worked too, but i'll remember ur simple tip in future ( my exam is pretty close.
regards,

nemo

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.