64,651
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
class cond
{
int i;
public:
cond( int );
cond& operator +=( cond a ) //顺便问一下这个怎么像构造函数一样定义到类定义的外面。
{
i += a.i;
return *this;
}
};
cond::cond( int a )
{
i = a;
}
cond operator +( cond a, cond b )
{
cond c = a;
return c += b;
}
int main()
{
cond test1( 3 );
cond test2( 4 );
if( test1 + test2 ); //这里报错。
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int a = 1;
int b = 2;
while( a + b );
return 0;
}
[/quote]
所以有什么问题么?
[/quote]
你用的不是常量么?我的意思是变量也可以。#include <iostream>
using namespace std;
int main()
{
int a = 1;
int b = 2;
while( a + b );
return 0;
}
[/quote]
所以有什么问题么?
#include <iostream>
using namespace std;
int main()
{
int a = 1;
int b = 2;
while( a + b );
return 0;
}