Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- class cricketer
- {
- protected:
- char name[25];
- int age;
- int no_of_match;
- public:
- void input()
- {
- cout<<"Enter the name";
- cin>>name;
- cout<<"enter the age";
- cin>>age;
- cout<<"Enter the total number of match";
- cin>>no_of_match;
- }
- void display()
- {
- cout<<"Name:"<<name;
- cout<<"Age:"<<age;
- cout<<"Total number of match:"<<no_of_match;
- }
- };
- class bowler:public cricketer
- {
- protected:
- int no_of_wickets;
- public:
- void input()
- {
- cricketer::input();
- cout<<"how many wickets:";
- cin>>no_of_wickets;
- }
- void display()
- {
- cricketer::display();
- cout<<"No of wickets:"<<no_of_wickets;
- }
- };
- class batsman:public cricketer
- {
- protected:
- int runs,no_of_centuries;
- public:
- void input()
- {
- cricketer::input();
- cout<<"how many runs:";
- cin>>runs;
- cout<<"How many centuries";
- cin>>no_of_centuries;
- }
- void display()
- {
- cricketer::display();
- cout<<"Total runs:"<<runs;
- cout<"Total centuries:"<<no_of_centuries;
- }
- };
- int main()
- {
- bowler b;
- batsman c;
- b.input();
- c.input();
- b.display();
- c.display();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement