When should the destructor be made virtual?

The v-ptr or virtual-function pointer is an implementation detail of virtual functions. Each object in a class with virtual functions has a virtual function pointer which points to the virtual function table for that class. The virtual function table is consulted when the compiler needs to determine which function to call in a particular situation.

Is percolating upward always a good thing?

Yes its a good thing, if we are percolating shared functionality upward in the program. BUt if all we are moving is interface that is not a good thing. That is, if all the derived classes can't use the method, its a mistake to move it up into a common base class. If we do, we will have to switch on the runtime type of the object before deciding if we can invoke the function.

When we can call the copy constructor in c++ ?

We can call copy constructer in the following situations:

  • when a function returns an object of that class by value
  • when the object of that class is passed by value as an argument to a function
  • when you construct an object based on another object of the same class
  • When compiler generates a temporary object
Why should I bother to declare anything on the free store?

Objects on the free store persist after the return of a function. In addition, the capability to store objects on the free store enables you to decide at runtime how many objects we need, instead of having to declare this in advance.

Which operator we can used to determine the address of a variable?

The address-of operator (&) is used to determine the address of any variable.

Why we use try blocks when we can use general exception handling?

Because try block will allow specific exception handling within that section of code. we get to have general handling for all code and specific handing for the code within the try block.

What is the difference between throw and a try ?

The throw statement will throw an exception automatically. But the try block contains code that might cause an exception to be thrown.

Define nested class.

Nested class means, a class can be define within another class. That is also called nested type. It is mostly used to define implementation classes.

Briefly explain union in c++?

Its just like a special kind of a class. It may have multiple data members, but at a time only one of the members may have a value.
When a value is assigned to one member of the union, all other members become undefined.

What is local class ?

A class can be defined local function body, is called local class. It defines a type that is visible only in the scope in which it is defined.