一个简单的类函数、就是不知道为什么输出不了80.求指导。
#include <iostream>using namespace std;
class renlei
{
public:
void huodeshengao(){cout<<shengao;}
void shezhishengao(int x){shengao=x;}
void huodetizhong();
void shezhitizhong(int x);
private:
int shengao;
int tizhong;
};
void renlei::shezhitizhong(int x)
{
tizhong=x;
}
void renlei::huodetizhong()
{
cout<<tizhong;
}
void main()
{
renlei kangqiu;
kangqiu.shezhishengao(8);
kangqiu.huodeshengao();
cout<<endl;
kangqiu.shezhitizhong(80); //为什么无法输出这个80.
kangqiu.huodetizhong;
}