Wrox Press C++ Tutorial
In this chapter, we've covered all of the principal ideas involved in using inheritance. The fundamentals that you should keep in mind are these:
private in the base class are not accessible in any derived class. To obtain the effect of the keyword private but allow access in a derived class, you should use the keyword protected in place of private.public, private, or protected. If none is specified, the default is private. Depending on the keyword specified for a base, the access level of the inherited members may be modified.virtual. This allows other definitions of the function appearing in derived classes to be selected at execution time, depending on the type of object for which the function call is made.virtual. This will ensure correct selection of a destructor for dynamically created derived class objects.friend of another class. In this case, all the function members of the friend class may access all the members of the other class. If class A is a friend of B, class B is not a friend of A unless it has been declared as such.=0 at the end of the function declaration. The class will then be an abstract class for which no objects can be created. In any derived class, all the pure virtual functions must be defined; if not, it too becomes an abstract class.virtual for derived classes when using multiple inheritance, in order to avoid duplicate occurrences of its data members in a class with multiple bases, two or more of which are derived from the indirect base.We have now gone through all of the important language features of C++, and by now you should be comfortable with most of them. You can go back and play with the source code to try out your new skills - you could try to extend the existing examples we've been through. Remember that the code for all of the examples is available for download form the Wrox Press website: http://www.wrox.com.