Thursday, 5 May 2016

Difference between pure virtual function and virtual function in C++


images.jpg

Pure virtual function
Pure Virtual Function is declared as
Ex : virtual return_type function_name(function arguments) = 0;
Virtual Function is declared with keyword 'virtual' at the declaration.
Ex : virtual return_type function_name(function arguments);
Pure-virtual functions need not be implemented in the base class, but they must be implemented in the derived classes.
Example:-
class Base {
// ...
virtual void f() = 0;
// ...
Virtual function
Virtual functions must be implemented in the base class, but they need not be implemented in their derived classes. Derived classes will automatically inherit the base class implementations of all virtual functions, but can override those functions by providing their own implementations.
Example:-
Derived d;
Base& rb = d;
// if Base::f() is virtual and Derived overrides it, Derived::f() will be called
rb.f();

Also Explore Findnerd about its Various Replenishing tools Like Project Management Tool, Desktop Recording Tool etc.