Hello all. Haven't asked a question here in a while.
Anyway, i am working on a game. I made the graphics class and now am working on a camera. I thought of making it so the camera would have a reference of the main world variable. So i tried doing that and can't figure out how.

// Array2D is the name of the graphics class I'm using
Array2D world(100,100); // a world 100x100
Array2D& worldRef = world;

^^ is what i want but in a class.

void Function(Array2D& a)
{
    a.PlotPixel(1,1,1); // plot 1 at 1,1
}

^^ is what i want but in a class
so i was trying but couldn't figure it out:

class Camera
{
public:
    Camera(Array2D& a) { worldRef = a; }
    ~Camera() {}
private:
    Array2D& worldRef;
};

i get the error:

1>.\main.cpp(8) : error C2758: 'Camera::worldRef' : must be initialized in constructor base/member initializer list
1>        .\main.cpp(10) : see declaration of 'Camera::worldRef'

Thanks

its done like this:

class Camera
{
public:
    Camera(Array2D& a): worldRef(a) {} 
    ~Camera() {}
private:
    Array2D& worldRef;
};

Really? i thought doing the :var(something) was just the same as =.
Wow tyvm

This question has already been answered. Start a new discussion instead.