Please explain the concept of virtual functions using a simple example and how its working is different from that of normal functions . Is there any special syntax for declaring these functions except the use of keyword Virtual
Code:// Making an interface for deriving classes class Base { public: // Deriving classes have to override the following function virtual void foo() = 0; }; // A class deriving from the base class class Derived : public Base { public: // Overrides and implements the function now void foo() { /* do something... */ } }; // ... Derived *dObj = new Derived; // Use it in some way delete dObj;
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks