lvalue required as left operand of assignment

hello everybody.
i'm trying to make a simple game in Irrlicht, for learning both C++ and Irrlicht itself. but i'm having trouble with a simple function. considering this code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class GameCamera{
    irr::scene::ICameraSceneNode* camera;

    public:
    irr::scene::ICameraSceneNode* getCameraNode();
};

class GameSys{
    GameCamera game_camera;
    irr::scene::ISceneManager* scenemgr;

    public:
    irr::scene::ISceneManager* getSceneMgr();
    int iniGameSys();
};

irr::scene::ICameraSceneNode* GameCamera::getCameraNode(){
    return camera;
}


and in iniGameSys() definition, we have this line:
game_camera.getCameraNode() = scenemgr->addCameraSceneNode(0, irr::core::vector3df(0,0,20), irr::core::vector3df(0,0,0));
which gives the error:
lvalue required as left operand of assignment

however, if i change "camera" to public in the class GameCamera, and try to acess like this:
game_camera.camera = scenemgr->addCameraSceneNode(0, irr::core::vector3df(0,0,20), irr::core::vector3df(0,0,0));
then i have no errors, and everything compiles fine. so, i guess it's not an Irrlicht error. i think it's some pointer or function i'm not handling correctly.

thanks in advance.
The pointer that is returned by game_camera.getCameraNode() is a copy of the game_camera.camera pointer. Assigning to the copy would be useless because the copy would be gone at the end of the line anyway so that's why it's not allowed. Why not add a function setCameraNode that you can use to set the pointer.
Last edited on
ook! i did as you suggested, works good.
i just wanted to know what i was doing wrong. once again, the scope strikes against me.

thanks for the help :)
Topic archived. No new replies allowed.