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.
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.
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
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.
The address-of operator (&) is used to determine the address of any variable.
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.
The throw statement will throw an exception automatically. But the try block contains code that might cause an exception to be thrown.
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.
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.
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.