When I try to compile my program, my Race.cc file has an error.
error: cannot bind non-const lvalue reference of type ‘Position&’ to an rvalue of type ‘Position’
view.update(tortoise->getCurrPos(), tortoise->getCurrPos(), tortoise->getAvatar());
~~~~~~~~~~~~~~~~~~~~^~
I'm struggling to figure out how to resolve these and would appreciate some help. I don't know why calling update(Position&, Position&, char)
from View.cc gets an error on the first parameter only and not the second considering I'm inputting the exact same thing. The line tortoise->getCurrPos()
should return a Position data type as shown in Runner.cc, and the parameter asks for a Position type so I don't get why it's not working.
Race.cc
Race::Race(){
Runner* tortoise = new Runner("Tortoise", 'T', 100, 1);
view.update(tortoise->getCurrPos(), tortoise->getCurrPos(), tortoise->getAvatar());
}
View.cc
void update(Position& oldPos, Position& newPos, char avatar){
}