| < Day Day Up > |
|
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.
List and describe the four basic object usage contexts.
Object creation
Object copying
Object assignment
Object destruction
other object contexts by design,,,
What is the orthodox canonical class form?
A recipe for writing well-behaved objects.
What four special functions support the OCCF?
Default constructor
Copy constructor
Destructor
Copy assignment operator
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.
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....
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.
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.
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.
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 > |
|