Untitled
unknown
plain_text
a year ago
738 B
3
Indexable
Never
#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(); }