Go to Post All I need now is a plow atachment for this year's robot - team 3311 [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 12-02-2012, 17:38
cjlane1138 cjlane1138 is offline
Team 1138
FRC #1138 (Eagle Engineering)
Team Role: Leadership
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Los Angeles
Posts: 88
cjlane1138 is an unknown quantity at this point
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?
__________________
Eagle Engineering 1138
Reply With Quote
  #2   Spotlight this post!  
Unread 12-02-2012, 18:08
cjlane1138 cjlane1138 is offline
Team 1138
FRC #1138 (Eagle Engineering)
Team Role: Leadership
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Los Angeles
Posts: 88
cjlane1138 is an unknown quantity at this point
Re: AxisCamera Declaration help

We figured it out:

Camera.h:
Code:
AxisCamera &camera;
Camera.cpp:
Code:
Camera::Camera():
camera(AxisCamera::GetInstance())
{
}
__________________
Eagle Engineering 1138
Reply With Quote
  #3   Spotlight this post!  
Unread 12-02-2012, 18:11
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: AxisCamera Declaration help

Quote:
Originally Posted by cjlane1138 View Post
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.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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