1.

What is an abstract class and where do we define the same?

Answer»

An abstract class is a class which has atleast one pure virtual function. An abstract class cant be instantiated be can be overridden in a derived class as below:

//Example below:

class Base { public: virtual VOID Get() = 0; virtual bool Get(int i) = 0; virtual int Get(FLOAT x) = 0; virtual ~Base() { } }; class Derived1 : public Base { bool value; public: void Get() { } bool Get(int i) { return i;} int Get(float x) { return (int)x;} }; class Derived2 : public Base { int value; public: void Get() { } bool Get(int i) { return i;} int Get(float x) { return (int)x;} }; int main() { int k=5; int temp = base->Get(k);   cout&LT;<"temp is"<<base->Get(k)<<ENDL; return 0; }


Discussion

No Comment Found