What is a constructor?
Constructors allow initialization of objects at the time of their creation.
Constructor function is a special function that is a member of the class and
has same name as that of the class. An object’s constructor..............
What are destructors?
Destructors are complements of constructors. When an object is destroyed, its
destructor is automatically called. Destructors are mainly useful for doing the
clean up job. E.g. an object may have..............
What are the
restrictions apply to constructors and destructors?
The following restrictions apply to constructors and destructors
Constructors and destructors don't return values.
The addresses of constructors and destructors can't be taken so we can't use
references and pointers on them...............
Explain the order in
which constructors are called when an object of a derived class is created.
The constructors of any virtual base classes are called first in the order of
inheritance...............
What is the difference
between a copy constructor and an assignment operator?
A copy constructor is used to declare and initialize an object from another
object. ..............
What is a virtual destructor?
Explain the use of it.
If the destructor in the base class is not made virtual, then an object that
might have been declared of type base class and instance of child class would
simply call the base class destructor without calling the derived class
destructor...............
How should a contructor handle a
failure?
Constructors don't have a return type, so it's not possible to use return codes.
The best way to signal..............
What are shallow and deep copy?
A shallow copy just copies the values of the data as they are. Even if there is
a pointer that points to dynamically allocated memory, the pointer in the copy
will point to the same dynamically allocated..............
What is virtual
constructors/destructors?
The explicit destroying of object with the use of delete operator to a base
class pointer to the object is performed by the destructor of the base-class is
invoked on that object................
|