#include<iostream.h>
#include<conio.h>
class base
{
private: int x;
float y;
public : virtual void getdata( );
virtual void display( );
};
class dev : public base
{
private: int roll;
char name[20];
public : void getdata( );
void display( );
};
void base :: getdata( ) { }
void base :: display( ) { }
void dev :: getdata( )
{
cout<<” Enter Roll of the Student “;
cin>> roll;
cout<<” Enter name of the student”;
cin>>name;
}
void dev :: display( )
{
cout<<”Name is :”<<name<<endl;
cout<<” Roll no is :”<<roll <<endl;
}
void main( )
{
base * ptr;
dev obj;
clrscr( );
ptr = &obj;
ptr -> getdata( );
ptr -> display( );
getch( );
}
OUTPUT
Enter the roll no of the student: 111
Enter the name of the student : Vijay
Name is : Vijay
Roll no is : 111
Not Satisfied ? Just search & get the result
Related posts:
- C++ program – Using class to generate mark sheet using multiple inheritance
- C++ class program – illestrate File operations
- C++ program – Perform complex arithmetic using operator overloading
- C++ program to implement Stack using Formula Based Representation
- C++ program to implement Heap sort Algorithm
