#include
using namespace std;
class CMax {
private:
int xx; int yy;
public:
CMax(int x,int y)
{ xx = x;yy = y ; }
void setValue(int x,int y)
{ xx = x;yy = y;}
int max( ){
return xx > yy? xx:yy;
}
};
void main( ){
CMax m( );
m.setValue(20,30);
cout <<″Max=″<<m.max( )<<endl;
}
C++改错题,基础不好,希望解释详细点。
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
5条回答 默认 最新
threenewbee 2018-08-01 12:21关注你这代码中的括号和大把的分号都是中文全角的。
();全部需要修改为 ();
CMax m(); 没有无参数构造函数,在public:里面加上
CMax() { }
#include 后面少<iostream>在现代的C++编译器上,比如vc++2015,main函数的返回值必须是int才符合标准,而不能是void
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报