#include<iostream.h> #include<math.h> class student{ friend class teacher; private:int id,clas; int math,physics; public: student(int id,int clas,int math,int physics) { id=id; clas=clas; math=math; physics=physics; } }; class teacher{ public : int sum1; teacher(student &a,student &b){ if(a.clas==1){ sum1+=a.math; } if(b.clas==1){ sum1+=b.math; } cout<<sum1<<endl; } }; voi
第1个回答 2014-10-30
id=id; clas=clas; math=math; physics=physics;
这里改一下:
this->id=id;
this->clas=clas;
this->math=math;
this->physics=physics;追问
这里改一下:
this->id=id;
this->clas=clas;
this->math=math;
this->physics=physics;追问
error C2228: left of '.id' must have class/struct/union type
追答你的代码没有贴完整?
本回答被提问者和网友采纳