大神帮忙看看这个程序哪儿错了,我是新手

2025-05-07 23:37:17
推荐回答(1个)
回答1:

#include 
using namespace std;

class Tree{
public:
Tree(int a){age=a;}
void grow(int years);
void age();
private:
int ages;
};

void Tree::grow(int years)
{

cout<<"请输入年份:"< ages+=years;
};

void Tree::age()
{

cout<<"此树的年龄为:"<};
int main()
{
Tree t1;
t1.age();
t1.grow(3);
t1.age();
system("PAUSE");
return 0;
}