Advertisement
Alysik

Untitled

Nov 26th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.55 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Individual {
  5.     protected:
  6.     string name;
  7. public:
  8.     virtual void input() = 0;
  9.     virtual void output() = 0;
  10. };
  11.  
  12. class Mammals : public Individual {
  13.     string name;
  14.     int amounts;
  15. public:
  16.     void input() {
  17.         cout << "Amount : " << endl;
  18.         cin >> amounts;
  19.         cout << " Name " << endl;
  20.         cin >> name;
  21.     }
  22.     void output() {
  23.         cout << "Amount of individual" << amounts << ". Name: " << name << endl;;
  24.     }
  25. };
  26.  
  27. class Artiodactyl : public Individual {
  28.     int amounts;
  29.     int weight;
  30. public:
  31.     void input() {
  32.         cout << "Amount : " << endl;
  33.         cin >> amounts;
  34.         cout << " Weight " << endl;
  35.         cin >> weight;
  36.     }
  37.     void output() {
  38.         cout << "Amount of individual" << amounts << ". Weight: " << weight<<endl;
  39.     }
  40. };
  41.  
  42. class Birds : public Individual {
  43.     int height;
  44.     int amounts;
  45.     int name;
  46. public:
  47.     void input() {
  48.         cout << "Amount : " << endl;
  49.         cin >> amounts;
  50.         cout << " Name " << endl;
  51.         cin >> name;
  52.         cout << " Height " << endl;
  53.         cin >> height;
  54.     }
  55.     void output() {
  56.         cout << "Amount of individual" << amounts << ". Name: " << name << ". Height: " << height << endl;;
  57.     }
  58. };
  59.  
  60. class Animals : public Individual{
  61.     int amounts;
  62. public:
  63.     void input() {
  64.         cout << "Amount : " << endl;
  65.     }
  66.     void output() {
  67.         cout << "Amount of individual" << amounts<<endl;
  68.     }
  69. };
  70.  
  71. int main()
  72. {
  73.     Individual* p = new Mammals ();
  74.     p->input();
  75.     p->output();
  76.     p = new Artiodactyl();
  77.     p->input();
  78.     p->output();
  79.     p = new Birds();
  80.     p->input();
  81.     p->output();
  82.     p = new Animals();
  83.     p->input();
  84.     p->output();
  85.     return 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement