Chapter 14

 < Day Day Up > 



Chapter 13

  1. Describe the differences between horizontal and vertical access. Describe how to use the keywords public, protected, and private to control horizontal and vertical access.

    Horizontal access is the access enjoyed by a client program to an object's members. The public access specifier allows horizontal access but protected and private prevent horizontal access.

    Vertical access is the access a derived class object has to base class object members. The access specifiers are used to specify what type of horizontal access inherited members will have in the derived class. (public inheritance, protected inheritance, or private inheritance)

  2. When can you get away with forward declaring a class name vs. including the whole header file?

    When you only need the name of the class and not the names of member functions or attributes.

  3. Describe, in your own words, the purpose of inheritance. In what two primary ways is inheritance used?

    Inheritance is used to extend the functionality of a class. Inheritance is used to evolve software design and to facilitate code reuse by having common class behavior located in base classes and inherited by derived classes.

  4. Describe how to hide a base class function with a derived class function.

    The base class function is non-virtual and the derived class function has the same name function signature as the base class function.

  5. How do you override a base class function in a derived class?

    The base class function is virtual and the derived class function has the same signature as the base class function. The overriding function is accessed via a base class pointer to a derived class object. (dynamic polymorphic behavior)

  6. What is a virtual function?

    A virtual function is one that may have an overriding implementation in a derived class

  7. What is a pure virtual function?

    A pure virtual function has no implementation in the class in which it's declared and must be implemented somewhere down the inheritance chain.

  8. What is the purpose of a virtual destructor?

    To ensure the destruction of a derived class object via a base class pointer.

  9. Describe how to achieve dynamic polymorphic behavior.

    Declare a base class pointer and assign it the address of a derived class object. Call a base class interface function and the derived class version will be called instead.

  10. In what part of a derived class constructor do you call the base class constructor?

    Initializer list



 < Day Day Up > 



C++ for Artists. The Art, Philosophy, and Science of Object-Oriented Programming
C++ For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504028
EAN: 2147483647
Year: 2003
Pages: 340
Authors: Rick Miller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net