Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   AxisCamera Declaration help (http://www.chiefdelphi.com/forums/showthread.php?t=102652)

cjlane1138 12-02-2012 17:38

AxisCamera Declaration help
 
We need help with declaring our axiscamera.

We already declared it like this:

Camera.cpp:
Code:

AxisCamera &camera = AxisCamera::GetInstance();
And this works, but we need it to be declared globally. Like this:

Camera.h:
Code:

AxisCamera *camera;
Camera.cpp:
Code:

&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

Re: AxisCamera Declaration help
 
We figured it out:

Camera.h:
Code:

AxisCamera &camera;
Camera.cpp:
Code:

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


RufflesRidge 12-02-2012 18:11

Re: AxisCamera Declaration help
 
Quote:

Originally Posted by cjlane1138 (Post 1125123)
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.


All times are GMT -5. The time now is 13:06.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi