怎么在类中定义输入成员函数?

2025-03-19 13:56:58
推荐回答(1个)
回答1:

我给你写了一个实例程序。你应该可以看懂,
就是专门解决你这个问题。不明白联系我。
#include
using namespace std;
class stu
{
public:
int age;
void getInfo()
{
int agee;
cin>>agee;
this->age=agee;
}
void showInfo()
{
cout< }
};
int main()
{
stu s;
s.getInfo();
s.showInfo();
return 0;
}