A static variable does exit though the objects for the respective class are not created. Static member variable share a common memory across all the objects created for the respective class. A static member variable can be referred using the class name itself.
• Public, protected and private are three access specifiers in C++.
• Public data members and member functions are accessible outside the class.
• Protected data members and member functions are only available to derived classes.
• Private data members and member functions can’t be accessed outside the class. However there is an exception can be using friend classes.
– Code isolation: All code that is to be handled when an exception raises is placed in the catch block, which is not part of the original code.
– The logic is pertaining to the type of the error, so that the developer can concentrate only on that exception.
– Developer can be selective about trapping various exceptions.
– The application should have a separate section called catch block. The code in which an exception is predicted is authored in the try block.
– 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.
– The above process can be simplified by declaring a virtual base class destructor.
– All the derived class destructors are made virtual in spite of having the same name as the base class destructor. In case the object in the hierarchy is destroyed explicitly by using delete operator to the base class pointer to a derived object, the appropriate destructor will be invoked.
– When a try block throws an exception, the program leaves the try block and enters the catch statement of the catch block.
– If they type of the object thrown matches the arg type in the catch block, catch block is executed for handling the code.
– If they are not caught, abort() function is executed by default.
– When no exception is deteted or thrown then the control goes to the statement below the catch block.
– The new operator allocates memory and returns a pointer to the start of it. The delete operator frees memory previously allocated using new.
Restrictions on static member functions are :
1. They can directly refer to other static members of the class.
2. Static member functions do not have this pointer.
3. Static member function can not be virtual.
A condition that should return true when a member function is invoked. In order to use a function correctly a precondition should return true. If a precondition fails to hold, an operation will not take responsibility to perform any action of sensibility. For example, the interface invariants of stack class respond nothing about pushing even though the stack is already full. In this scenario, sinful () is a precondition for push operation.
A condition that should return true before returning from an invoked function. In order to use a function correctly a post condition should return true. Taking a stack as an example, is empty () must necessarily be true after pushing the element into the stack when an element is pushed. The function is empty () is a post condition.
– A pointer declaration consists of a base type, an *, and the variable name.
A void pointer is a special pointer that points to an unspecified object. A null pointer can not be dereferenced. The address manipulation can directly be done by pointer casting to and from an integral type of sufficient size.