#include <iostream>
#include <string>
using namespace std;
struct Animal {
string name;
string type;
string color;
int age;
double weight;
void increaseWeight(int days) {
weight += weight * 0.01 * days;
}
void changeName(string newName) {
name = newName;
}
void displayAnimal() {
cout << "Name: " << name << endl;
cout << "Type: " << type << endl;
cout << "Color: " << color << endl;
cout << "Age: " << age << endl;
cout << "Weight: " << weight << endl;
}
};
int main() {
// Статический объект
Animal animal1 = {
"Barsik",
"Cat",
"Black",
3,
5.0
};
// Динамический объект
Animal* animal2 = new Animal{
"Bobik",
"Dog",
"White",
5,
12.0
};
// Методы статического объекта
animal1.increaseWeight(10);
animal1.changeName("Murzik");
animal1.displayAnimal();
cout << endl;
// Методы динамического объекта
animal2->increaseWeight(7);
animal2->changeName("Sharik");
animal2->displayAnimal();
delete animal2;
return 0;
}