What is virtual class and friend class?

Friend classes are used when two or more classes are designed to work together and need access to each other’s implementation in ways that the rest of the world shouldn’t be allowed to have. In other words, they help keep private things private. For instance, it may be desirable for class Database Cursor to have more privilege to the internals of class Database than main() has.

What is the difference between Virtual function and Pure Virtual function?

A virtual function makes its class a polymorphic base class. Derived classes can override virtual functions. Virtual functions called through base class pointers/references will be resolved at run-time. That is, the dynamic type of the object is used instead of its static type:

Derived d;  Base& rb = d;  // if Base::f() is virtual and Derived overrides it, Derived::f() will be called  rb.f();

A pure virtual function is a virtual function whose declaration ends in =0:

class Base {   // ...   virtual void f() = 0;   // ...

A pure virtual function makes the class it is defined for abstract. Abstract classes … Click here to continue reading.

Explain about abstraction?

Abstraction can also be achieved through composition. It solves a complex problem by defining only those classes which are relevant to the problem and not involving the whole complex code into play.

The vehicle class described above is an example of abstraction. Abstraction is the process of representing simplified versions of real-world objects in your classes and objects. The car class does not describe every possible detail of a car, only the relevant parts for the system being developed. Modelling software around real-world objects can vastly reduce the time required to understand a solution and be able to develop and … Click here to continue reading.