//A program to
illustrate how to declare a pure virtual function and equate it to zero as it
// does not have any function parts.//
#include <iostream.h>
#include <conio.h>
class base {
private :
int x;
float y;
public :
virtual inline void getdata() = 0;
virtual inline void display() = 0;
};
class derivedB :
public base {
private :
long int
rollno;
char name[20];
public :
void getdata();
void display();
};
void derivedB
:: getdata()
{
cout << "
enter roll no of student \n";
cin >> rollno;
cout
<< " enter name of a student \n";
cin >> name;
}
void derivedB
:: display()
{
cout << "
roll number, stdent's name \n";
cout << rollno << '\t'
<< name << endl;
}
void main()
{
clrscr();
base *ptr;
derivedB obj;
ptr=&obj;
ptr->getdata();
ptr->display();
getch();
}
No comments:
Post a Comment