3.2.3. Abstract Classes
Q21. Write about Abstract Classes.
Answer:
Abstract Classes
Abstract classes are the classes that contain only function declaration, but not its definition. That is, it provides just the skeleton of the class hiding the implementation details. These classes are extendable and can even contain virtual functions, which help the programmer to debug the bugs.
Abstract classes are defined in'a header file called abstract.h.
Example
Output
Answer:
Abstract Classes
Abstract classes are the classes that contain only function declaration, but not its definition. That is, it provides just the skeleton of the class hiding the implementation details. These classes are extendable and can even contain virtual functions, which help the programmer to debug the bugs.
Abstract classes are defined in'a header file called abstract.h.
Example
#include <iostream.h>
#include <conio.h>
const int max = 80;
class first
{
protected:
char name[max];
char cls[max];
public:
virtual void insert()=0;
virtual void show()=0;
}
class second : public first
{
protected:
int fees;
public:
void insert()
{
cout<<“Name”;
cin>>name;
cout<<“Class”;
cin>>cls;
cout<<“Fees”;
cin>>fees;
}
void show()
{
cout<<“\nName:”<<name<<“\n”;
cout<<“Class:”<<cls<<“\n”;
cout<<“Fees:”<<fees<<"\n”’;
}
};
void main()
{
clrscr();
second s1;
sl.insert();
sl.show();
getch();
}
Output