C++改错题,基础不好,希望解释详细点。

#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;
}

POPMUISE
浏览 603回答 1
1回答

人到中年有点甜

你这代码中的括号和大把的分号都是中文全角的。();全部需要修改为 ();CMax m(); 没有无参数构造函数,在public:里面加上CMax() { }#include 后面少<iostream>在现代的C++编译器上,比如vc++2015,main函数的返回值必须是int才符合标准,而不能是void
打开App,查看更多内容
随时随地看视频慕课网APP