Загрузка данных


#include <iostream>
#include <string>
using namespace std;

struct Animal
{
    string name;
    string type;
    string color;
    int age;
    double weight;

    void eat(int days)
    {
        weight = weight + weight * 0.01 * days;
    }

    void changeName(string newName)
    {
        name = newName;
    }

    void show()
    {
        cout << "Имя: " << name << endl;
        cout << "Вид: " << type << endl;
        cout << "Окрас: " << color << endl;
        cout << "Возраст: " << age << endl;
        cout << "Вес: " << weight << endl;
        cout << endl;
    }
};

Animal a1;

int main()
{
    a1.name = "Барсик";
    a1.type = "Кот";
    a1.color = "Серый";
    a1.age = 3;
    a1.weight = 4.5;

    Animal* a2 = new Animal;

    a2->name = "Шарик";
    a2->type = "Собака";
    a2->color = "Рыжий";
    a2->age = 5;
    a2->weight = 12.0;

    a1.eat(5);
    a1.changeName("Мурзик");
    a1.show();

    a2->eat(3);
    a2->changeName("Бобик");
    a2->show();

    delete a2;

    return 0;
}