What is a
constructor?
Latest answer: 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..............
Read answer
What are
destructors?
Latest answer: 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..............
Read
answer
What are
the restrictions apply to constructors and destructors?
Latest answer: 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...............
Read
answer
Explain the
order in which constructors are called when an object of a derived
class is created.
Latest answer: The
constructors of any virtual base classes are called first in the
order of inheritance...............
Read
answer
What is the
difference between a copy constructor and an assignment
operator?
Latest answer: A copy
constructor is used to declare and initialize an object from another
object. ..............
Read
answer
What is a virtual
destructor? Explain the use of it.
Latest answer: 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...............
Read answer
How should a
contructor handle a failure?
Latest answer: Constructors
don't have a return type, so it's not possible to use return codes.
The best way to signal..............
Read answer
What are shallow and
deep copy?
Latest answer: 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..............
Read answer
What is
virtual constructors/destructors?
Latest answer: 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................
Read
answer