ФуКласс.h:
class FooClass {
.
.
.
private:
World *myWorld;
const Player *&player;
.
.
.
}
Фукласс.cpp:
FooClass::FooClass(..., World *w) : myWorld(w), player(w->getPlayer())
{
.
.
.
}
Это вызывает следующую ошибку: Non-const lvalue reference to type 'const Player *' cannot bind to a temporary of type 'Player *'
. Тем не менее, lvalue типа const Player *
явно является константным lvalue...
const Player *
— это тип, а не lvalue. Все, что возвращаетw->getPlayer()
, являетсяPlayer *
. - person chris   schedule 12.09.2014