#include <iostream.h>
#include <string.h>
#include <conio.h>
class Person
{
protected :
char name[30];
int age;
public :
void getPersonData( char *n, int a)
{
strcpy(name,n);
age = a;
}
};
class Typist
{
protected :
int speed;
public :
void getTypingSpeed( int s)
{
speed = s;
}
};
class Staff : public Person, public Typist
{
private :
char department[30];
public :
void getDepartment( char * dpt)
{
Strcpy(department, dpt)
}
void showDetails( )
{
cout<<”Name :”<<name<<”\n”;
cout<<”Age :”<<age<<”\n”;
cout<<”Speed :”<<speed<<”\n”;
cout<<”Department :”<<department<<”\n”;
}
};
void main( )
{
Staff myStaff;
myStaff.getPersonData(“Ramesh”, 32);
myStaff.getSpeed(60);
myStaff.getDepartment(“Library”);
myStaff.showDetails( );
}
Output :
Name : Ramesh
Age : 32
Speed : 60
Department : Library
#include <string.h>
#include <conio.h>
class Person
{
protected :
char name[30];
int age;
public :
void getPersonData( char *n, int a)
{
strcpy(name,n);
age = a;
}
};
class Typist
{
protected :
int speed;
public :
void getTypingSpeed( int s)
{
speed = s;
}
};
class Staff : public Person, public Typist
{
private :
char department[30];
public :
void getDepartment( char * dpt)
{
Strcpy(department, dpt)
}
void showDetails( )
{
cout<<”Name :”<<name<<”\n”;
cout<<”Age :”<<age<<”\n”;
cout<<”Speed :”<<speed<<”\n”;
cout<<”Department :”<<department<<”\n”;
}
};
void main( )
{
Staff myStaff;
myStaff.getPersonData(“Ramesh”, 32);
myStaff.getSpeed(60);
myStaff.getDepartment(“Library”);
myStaff.showDetails( );
}
Output :
Name : Ramesh
Age : 32
Speed : 60
Department : Library
0 comments:
Post a Comment