views:

67

answers:

2

When having a base class with pure virtual methods this makes it so that the class can not be instantiated. If I have regular methods and attributes in this base class does the derived classes still inherit those as normal?

For e.g. a getter and setter for an attribute.

+2  A: 

Yes, all methods are inherited.

Zepplock
Private methods are inherited just as well - they're private, sure, but friends can still see them.
Pavel Minaev
They are still inherited even if private - it's just that they are inherited as private methods etc, so they can't be referenced. For example, an inherited private field still takes up space in instances of the class, and still holds a value that might affect the results from (non-private) inherited methods.
Steve314
Private inherited functions can be called by the base class. So, they can still be used to change behavior. You just can't call them outside of the base class. All private, protected, and public indicate is who can call the functions.
Jonathan M Davis
Thanks. Fixed. For some reason I assumed he wanted to know if other classes can access it.
Zepplock
A: 

As Moron said, try it yourself. But, to put more structure around the topic...

There is interface inheritance (what methods can I call on an object?) and implementation inheritance (what code gets called when I call this method on this object?). Pure virtual methods provide interface inheritance, but not implementation inheritance. A virtual (but non-pure) method provides both, with the option to allow a derived class to provide a different implementation. A non-virtual method provides both, without the option to allow a derived class to provide a different implementation.

Darryl