Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Individual {
- protected:
- string name;
- public:
- virtual void input() = 0;
- virtual void output() = 0;
- };
- class Mammals : public Individual {
- string name;
- int amounts;
- public:
- void input() {
- cout << "Amount : " << endl;
- cin >> amounts;
- cout << " Name " << endl;
- cin >> name;
- }
- void output() {
- cout << "Amount of individual" << amounts << ". Name: " << name << endl;;
- }
- };
- class Artiodactyl : public Individual {
- int amounts;
- int weight;
- public:
- void input() {
- cout << "Amount : " << endl;
- cin >> amounts;
- cout << " Weight " << endl;
- cin >> weight;
- }
- void output() {
- cout << "Amount of individual" << amounts << ". Weight: " << weight<<endl;
- }
- };
- class Birds : public Individual {
- int height;
- int amounts;
- int name;
- public:
- void input() {
- cout << "Amount : " << endl;
- cin >> amounts;
- cout << " Name " << endl;
- cin >> name;
- cout << " Height " << endl;
- cin >> height;
- }
- void output() {
- cout << "Amount of individual" << amounts << ". Name: " << name << ". Height: " << height << endl;;
- }
- };
- class Animals : public Individual{
- int amounts;
- public:
- void input() {
- cout << "Amount : " << endl;
- }
- void output() {
- cout << "Amount of individual" << amounts<<endl;
- }
- };
- int main()
- {
- Individual* p = new Mammals ();
- p->input();
- p->output();
- p = new Artiodactyl();
- p->input();
- p->output();
- p = new Birds();
- p->input();
- p->output();
- p = new Animals();
- p->input();
- p->output();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement