你题目的解答代码如下:
#include<iostream>
#include<stdio.h>
using namespace std;
class tree
{
private:
int ages;
public:
tree(int a)
{
ages = a;
}
void years(int y)
{
ages += y;
}
int getAge()
{
return ages;
}
};
int main()
{
int ages,years;
scanf("%d%d", &ages,&years);
tree tr(ages);
tr.years(years);
printf("%d",tr.getAge());
return 0;
}
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!