Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
738 B
4
Indexable
#include <iostream>
#include <cstdlib>
using namespace std;

class Zoo {
	private:
		string animal;
		string color;
		int age;
	public:
		Zoo() {
			animal = "Lynx";
			color = "Yellow";
			age = 5;
		}
		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 << "Species: " << animal << endl;
			cout << "Color: " << color << endl;
			cout << "Age: " << age << endl;
		}

};

int main() {
	Zoo bear("bear", "brown", 10);
	Zoo lynx;
	Zoo hare("hare", "white", 2);
	Zoo *ptr = &hare;
	(*ptr).get_data();
	ptr->get_data();
}