Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
800 B
3
Indexable
#include <iostream>
using namespace std;

class Zoo {
private:
    string animal;
    string color;
    int age;

public:
    Zoo() { 
        animal = "elephant";
        color = "gray";
        age = 2;
    }

    Zoo(string _animal, string _color, int _age) { 
        set_data(_animal, _color, _age);
    }

    void set_data(string _animal, string _color, int _age) { 
        animal = _animal;
        color = _color;
        age = _age;
    }

    void get_data() {
        cout << animal << " " << color << " " << age << endl;
    }
};

int main()
{
    Zoo one;
    Zoo two("giraffe", "brown", 3);
    Zoo* three = &two;

    one.get_data();
    two.get_data();

    three->set_data("crocodile", "green", 13);
    three->get_data();
    return 0;
}