--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
c:\my documents\cpp1.cpp(5) : error C2803: 'operator +' must have at least one formal parameter of class type
c:\my documents\cpp1.cpp(8) : error C2803: 'operator +' must have at least one formal parameter of class type
Error executing cl.exe.
int operator +(int a,int b)
{
a=a+2;
return a;
}
这样做有什么意思吗?还不如直接写一个函数得了,重载主要是对类进行重载'operator +' must have at least one formal parameter of class type就是这个意思!