Log in

View Full Version : AxisCamera Declaration help


cjlane1138
12-02-2012, 17:38
We need help with declaring our axiscamera.

We already declared it like this:

Camera.cpp:
AxisCamera &camera = AxisCamera::GetInstance();

And this works, but we need it to be declared globally. Like this:

Camera.h:
AxisCamera *camera;

Camera.cpp:
&camera = AxisCamera::GetInstance();

But this does not seem to work. The reason we need it global is because we want to be able to access it in other classes, such as MyRobot.

How can we do this?

cjlane1138
12-02-2012, 18:08
We figured it out:

Camera.h:
AxisCamera &camera;

Camera.cpp:
Camera::Camera():
camera(AxisCamera::GetInstance())
{
}

RufflesRidge
12-02-2012, 18:11
How can we do this?

The whole idea behind a singleton and GetInstance is that you can just call GetInstance wherever you need to access the object. Just put a separate GetInstance call in whatever classes you need the camera object in.