Untitled
unknown
plain_text
2 years ago
953 B
3
Indexable
Never
#include <iostream> using namespace std; class zoo { private: string animals; string color; int age; public: zoo() { animals = "Lions"; color = "white"; age = 5; } zoo(string _animals, string _color, int _age) { set_data(_animals, _color, _age); } void set_data(string _animals, string _color, int _age) { animals = _animals; color = _color; age = _age; } void get_data() { cout << animals << " " << color << " " << age << endl; } }; int main() { zoo first; zoo second("Horses", "Black", 8); zoo third("Elephants", " Grey", 5); zoo* pointer = &second; first.get_data(); second.get_data(); third.get_data(); (*pointer).get_data(); pointer->get_data(); pointer->set_data("Zebras", "Black and white", 4); pointer->get_data(); return 0; }