|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools |
Rating:
|
Display Modes |
|
|
|
#1
|
|||
|
|||
|
Re: Error: within this context
You've added a data member called camera, of type AxisCamera, no problem there. But the code you've included has a constructor with an initialization list, and you haven't added a value for camera field.
Not being that familiar with the C++ WPI code, the issue is likely that the AxisCamera doesn't have a default constructor or for some other reason, the compiler wants camera to be assigned using the initialization list. Try putting camera(???) after the controller(1) line and before the {. Replace ??? with the parameters required for an AxisCamera object to be initialized. Gotta love compiler error messages sometimes. Greg McKaskle |
|
#2
|
||||
|
||||
|
Re: Error: within this context
AxisCamera is a singleton. You shouldn't be calling the constructor directly. Try this.
Code:
AxisCamera& camera; //In your constructor do this camera = AxisCamera::GetInstance(); Last edited by Dave Scheck : 09-12-2010 at 10:13. Reason: Changed my pointer to a reference to match the prototype |
|
#3
|
|||
|
|||
|
Re: Error: within this context
Thanks for the reply. It looks like I have a different problem now. When I try to implement your suggestion and use:
Code:
camera = AxisCamera::GetInstance(); Thanks again. |
|
#4
|
||||
|
||||
|
Re: Error: within this context
You should declare the camera as:
Code:
AxisCamera &camera; camera = AxisCamera::GetInstance(); |
|
#5
|
||||
|
||||
|
Re: Error: within this context
Thanks for the correction mikets. I misread the header when I wrote my initial post. I updated it to have the reference declaration instead of a pointer.
|
|
#6
|
|||
|
|||
|
Re: Error: within this context
I really appreciate both of your replies, but making the corrections you suggested has led me to another problem.
Code:
class RobotDemo : public SimpleRobot
{
RobotDrive myRobot; // robot drive system
Gamepad controller;
AxisCamera& camera;
public:
RobotDemo(void):
myRobot(10, 9, 2, 1),
controller(1)
{ <-------------------------ERROR HERE
GetWatchdog().SetExpiration(0.1);
camera = AxisCamera::GetInstance(); <--------ERROR HERE
The second error gets me back to where I started. It says "error within this context". This feels like one step forward then two steps back. Thanks for your help. |
|
#7
|
||||
|
||||
|
Re: Error: within this context
Quote:
try this: Code:
class RobotDemo : public SimpleRobot
{
RobotDrive myRobot; // robot drive system
Gamepad controller;
AxisCamera& camera;
public:
RobotDemo(void):
myRobot(10, 9, 2, 1),
controller(1),
camera(AxisCamera::GetInstance())
{
GetWatchdog().SetExpiration(0.1);
Ex (bold is error in code) file.cpp: In constructor `ZomBDashboardPacketSender::ZomBDashboardPacketSen der()': file.cpp:301: error: uninitialized reference member `ZomBDashboardPacketSender::hp' WPILib/Dashboard.h:58: error: `void Dashboard::operator=(const Dashboard&)' is private file.cpp:302: error: within this context Last edited by byteit101 : 09-12-2010 at 18:08. Reason: expanding |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What's this number 80 in error math? | K.Porter | Programming | 3 | 25-01-2007 18:28 |
| Glitches Eliminated using Interrupt Context Saving, BUT ... | mluckham | Programming | 22 | 09-01-2007 17:19 |
| Trying to follow C18 interrupt context code... | dcbrown | Programming | 5 | 21-12-2006 09:01 |
| What is this error message? | chantilly_team | Programming | 3 | 22-01-2005 10:09 |
| Explain this link error? | Larry Barello | Programming | 1 | 16-01-2004 11:06 |