WAP to show the working of abstract class by considering suitable example.
#include<iostream>
using namespace std;
class AbstractClass
{
int data;
public:
virtual void pureFunction() = 0;
int getData() { return data; }
};
class DerivedClass: public AbstractClass
{
int x;
public:
void pureFunction() { cout << "pureFunction() called"; }
};
int main(void)
{
DerivedClass derived;
derived.pureFunction();
return 0;
}
Comments
Leave a comment