请问(1)(2)题怎么搞啊?T﹏T刚刚学C++的,啥也不会

img

这个怎么弄啊?学了一个学期的C++还是没有搞会,马上要期末考试了,有没有人可以教我呀?谢谢了

(1)

#include <iostream>
using namespace std;
class Animal{
private:
    float age,height,weight;
public:
    Animal(float age,float height,float weight){
        this->age = age;
        this->height = height;
        this->weight = weight;
    }
    void eat();
    void do_sports();
    void sleep();
    void print_info();
};

void Animal::eat(){
    weight+=1;
}

void Animal::do_sports(){
    height+=1;
}

void Animal::sleep(){
    age+=0.5;
    weight+=0.5;
    height+=0.5;
}

void Animal::print_info(){
    cout<<"age: "<<age<<"weight: "<<weight<<"height: "<<height;
}

int main(){
    Animal panda(17,180,120);
    panda.eat();
    panda.sleep();
    panda.eat();
    panda.do_sports();
    panda.print_info();
}