Potion of my code:
class UserCommand{
string cHandle; //definition of command
int numPara;
vector<int> cPara; //parameter of command
public:
UserCommand(string ucData);
//copy constructor
UserCommand(const UserCommand& uc);
inline const string getHandle(){return cHandle;};
inline const int getPara(int i){return cPara.at(i);};
inline const int getNumPara(){return numPara;};
//overload operator = here
inline UserCommand operator=(UserCommand& uc);
}; //
//...
UserCommand::UserCommand(const UserCommand& uc){
cHandle=uc.getHandle();
numPara=uc.getNumPara();
for(int i=0;i<numPara;i++) cPara[i]=uc.getPara(i);
}
Pretty straighforward. But I keep got error:
error: passing `const UserCommand' as `this' argument of `std::string UserCommand::getHandle()' discards qualifiers
I am using gcc under redhat, anyone can help me on this? thanks in advance.