#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;}
1 回答

人到中年有點(diǎn)甜
TA貢獻(xiàn)1895條經(jīng)驗(yàn) 獲得超7個(gè)贊
你這代碼中的括號(hào)和大把的分號(hào)都是中文全角的。
();全部需要修改為 ();
CMax m(); 沒(méi)有無(wú)參數(shù)構(gòu)造函數(shù),在public:里面加上
CMax() { }
#include 后面少<iostream>
在現(xiàn)代的C++編譯器上,比如vc++2015,main函數(shù)的返回值必須是int才符合標(biāo)準(zhǔn),而不能是void
- 1 回答
- 0 關(guān)注
- 629 瀏覽
添加回答
舉報(bào)
0/150
提交
取消