Chapter 18

 < Day Day Up > 



Chapter 17

  1. Describe in your own words why it is important to have well-behaved objects in an object-oriented software application.

    So you can accurately predict the behavior of objects in your program. This will lead to more reliable code.

  2. List and describe the four basic object usage contexts.

    Object creation

    Object copying

    Object assignment

    Object destruction

    other object contexts by design,,,

  3. What is the orthodox canonical class form?

    A recipe for writing well-behaved objects.

  4. What four special functions support the OCCF?

    Default constructor

    Copy constructor

    Destructor

    Copy assignment operator

  5. Why is it important to be aware of all the contexts an object will participate?

    So your object behave predictably when they are used in a program.

  6. List several examples of object context participation that have not been discussed in this chapter.

    Comparing objects in a sorting program

    Comparing contents of text message objects

    etc....

  7. List several examples of why it would be a mistake to rely on a compiler generated constructor and destructor.

    The default constructor and destructor will not properly initialize complex object. For instance, a default constructor will not automatically initialize a pointer, and the default destructor will not destroy the pointer either.

  8. What is the definition of a default constructor?

    A default constructor has default values for all parameters. It can therefore be called with no arguments (setting all object attributes to default values) or with arguments as required. A default constructor generally alleviates the need to overload the constructor.

  9. How does a copy constructor differ from a copy assignment operator?

    A constructor creates a new object.

    A copy constructor creates a new object using an existing object as a guide.

  10. What is the purpose of a destructor?

    To tear down the object in memory and release any system resources back to the operating system.



 < 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