![]() |
Error: within this context
I'm trying to add the code for the Axis camera and I keep seeing this error when I build the project "error: within this context".
#include "WPILib.h" #include "Gamepad.h" #include "Vision/AxisCamera.h" class RobotDemo : public SimpleRobot { RobotDrive myRobot; // robot drive system Gamepad controller; AxisCamera camera; public: RobotDemo(void): myRobot(10, 9, 2, 1), // these must be initialized in the same order controller(1) { <------ERROR HERE All I did was add the AxisCamera header file and the identifier (AxisCamera camera). What am I missing? Thanks. |
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 |
Re: Error: within this context
AxisCamera is a singleton. You shouldn't be calling the constructor directly. Try this.
Code:
AxisCamera& camera; |
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. |
Re: Error: within this context
You should declare the camera as:
Code:
AxisCamera &camera; |
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.
|
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 SimpleRobotThe 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. |
Re: Error: within this context
Quote:
try this: Code:
class RobotDemo : public SimpleRobotEx (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 |
| All times are GMT -5. The time now is 13:26. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi