Advertisement
Guest User

Untitled

a guest
May 22nd, 2022
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. class cricketer
  4. {
  5. protected:
  6.     char name[25];
  7.     int age;
  8.     int no_of_match;
  9. public:
  10. void input()
  11. {
  12.     cout<<"Enter the name";
  13.     cin>>name;
  14.     cout<<"enter the age";
  15.     cin>>age;
  16.     cout<<"Enter the total number of match";
  17.     cin>>no_of_match;
  18. }
  19. void display()
  20. {
  21.     cout<<"Name:"<<name;
  22.     cout<<"Age:"<<age;
  23.     cout<<"Total number of match:"<<no_of_match;
  24. }
  25. };
  26. class bowler:public cricketer
  27. {
  28. protected:
  29.     int no_of_wickets;
  30. public:
  31. void input()
  32. {
  33.     cricketer::input();
  34.     cout<<"how many wickets:";
  35.     cin>>no_of_wickets;
  36. }
  37. void display()
  38. {
  39.     cricketer::display();
  40.     cout<<"No of wickets:"<<no_of_wickets;
  41. }
  42. };
  43. class batsman:public cricketer
  44. {
  45. protected:
  46.     int runs,no_of_centuries;
  47. public:
  48. void input()
  49. {
  50.     cricketer::input();
  51.     cout<<"how many runs:";
  52.     cin>>runs;
  53.     cout<<"How many centuries";
  54.     cin>>no_of_centuries;
  55. }
  56. void display()
  57. {
  58.     cricketer::display();
  59.     cout<<"Total runs:"<<runs;
  60.     cout<"Total centuries:"<<no_of_centuries;
  61. }
  62. };
  63. int main()
  64. {
  65.     bowler b;
  66.     batsman c;
  67.     b.input();
  68.     c.input();
  69.     b.display();
  70.     c.display();
  71.     return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement