主题:这是为什么呢
#include<iostream>
using namespace std;
class A{int a;
int b;
public:
int geta(){return a;}
int getb(){return b;}};
ostream & operator<<(ostream &out,A&a){
out<<a.geta()<<endl<<a.getb()<<endl;
return (out);}
int main(){A a;
a.geta()=21;
a.getb()=32;
cout<<a;}
pp1.cpp
C:\Users\qz\Desktop\Cpp1.cpp(12) : error C2106: '=' : left operand must be l-value
C:\Users\qz\Desktop\Cpp1.cpp(13) : error C2106: '=' : left operand must be l-value
C:\Users\qz\Desktop\Cpp1.cpp(14) : warning C4508: 'main' : function should return a value; 'void' return type assumed
执行 cl.exe 时出错.
Cpp1.obj - 1 error(s), 0 warning(s)
啥意思呀 ??????????????
using namespace std;
class A{int a;
int b;
public:
int geta(){return a;}
int getb(){return b;}};
ostream & operator<<(ostream &out,A&a){
out<<a.geta()<<endl<<a.getb()<<endl;
return (out);}
int main(){A a;
a.geta()=21;
a.getb()=32;
cout<<a;}
pp1.cpp
C:\Users\qz\Desktop\Cpp1.cpp(12) : error C2106: '=' : left operand must be l-value
C:\Users\qz\Desktop\Cpp1.cpp(13) : error C2106: '=' : left operand must be l-value
C:\Users\qz\Desktop\Cpp1.cpp(14) : warning C4508: 'main' : function should return a value; 'void' return type assumed
执行 cl.exe 时出错.
Cpp1.obj - 1 error(s), 0 warning(s)
啥意思呀 ??????????????