Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Animal {
- private:
- string name;
- int age, weight;
- public:
- Animal() {}
- Animal(string _name, int _age, int _weight) {
- name = _name;
- age = _age;
- weight = _weight;
- }
- Animal(const Animal & tmp) {
- name = tmp.name;
- age = tmp.age;
- weight = tmp.weight;
- }
- string get_name() {
- return name;
- }
- void set_name(string _name) {
- name = _name;
- }
- };
- class Cat : public Animal {
- private:
- string breed;
- string color;
- public:
- Cat() : Animal() {}
- Cat(string _name, int _age, int _weight, string _breed, string _color) : Animal(_name, _age, _weight) {
- breed = _breed;
- color = _color;
- }
- Cat(const Cat & tmp) : Animal(tmp) {
- breed = tmp.breed;
- color = tmp.color;
- }
- void print() {
- cout << get_name() << " " << breed << " " << color << endl;
- }
- };
- int main()
- {
- Cat c("Garfield", 12, 150, "orange", "orange");
- c.print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement