C++ returning pointers value not changeable
I have run into a strange problem. When i try to write a function that
returns a pointer to a subclass which i swap for a different instance of
that subclass i get the "error C2106: '=' : left operand must be l-value"
error.
Tthe problems is at the one->getMe() = two; line :
class subClass{};
class someClass{
public:
subClass * pointer;
someClass(){
pointer = new subClass;
}
subClass * getMe(){
return pointer;
}
};
int main(){
someClass * one = new someClass;
subClass * two = new subClass;
one->getMe() = two;
}
I'm a bit new to c++ so the problem might be horrible simple. Any help is
much appreciated.
No comments:
Post a Comment