Page 227 - DCAP404 _Object Oriented Programming
P. 227
Object-oriented Programming
Notes {
}
void employee:: display ( )
{
}
void grade:: getdata ()
{
cout<<“ enter employee’s grade “;
cin> > grd;
cout<< “\n enter the salary “;
cin>> salary;
}
void grade:: display ( )
{
cout<<“ Grade salary \n”;
cout<< grd<<“ “<< salary<< end1;
}
void main ( )
{
employee *ptr;
grade obj;
ptr = &obj;
ptr->getdata ( );
ptr->display ( );
getche();
}
Output
enter employee’s grade A
enter the salary 250000
Grade salary
A 250000
Another format can have a pure virtual function when a virtual function is declared within the
class declaration itself. The virtual function may be equated to zero if it does not have a function
definition. Such functions are also called as do-nothing functions.
Task A Pure Virtual Function is a Virtual function with no body. Explain with an example.
220 LOVELY PROFESSIONAL UNIVERSITY