operator= function not working?
Hey guys,
I'm trying to do something very simple, which is to get a Platform object using a function
Platform retrieve(int n)
from a CTrainList object, which is like a linked list that holds Platforms.
Here's the code (which appears as a function in main):
1 2 3 4 5 6 7
|
void displayStations(CTrainLine rLine, CTrainLine bLine){
Platform temp;
for(int n = 1; n < rLine.getSize()+1; n++){
temp = rLine.retrieve(n);
cout << "Got platform " << n << endl;
}
}
|
But it's giving me this error:
4: no match for 'operator=' in 'temp = CTrainLine::retrieve(int)(n)'
4: candidates are: Platform Platform::operator=(Platform&)
|
What's confusing me is that I DO have an operator= function that returns a Platform object:
1 2 3 4 5
|
Platform Platform::operator=(Platform &p2){
Platform result(p2.getStation(),p2.getLine(),p2.getDirection());
result.setTrain(p2.hasTrain());
return result;
}
|
Also, here's the retrieve function for reference:
1 2 3 4
|
Platform CTrainLine::retrieve(int pos){
ListNode * curr = find(pos);
return *(curr->data); //data is a pointer to a platform.
}
|
Does anyone have any idea what it's not letting me retrieve this object? It seems very unusual.
Thank you very much!
Last edited on
Topic archived. No new replies allowed.