|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: Pointers and Tank Drive?
void OperatorControl(void)
{ while (1) { Bot->TankDrive(&stickLeft, &stickRight); } } }; I tried that and here are the errors that r showing up! The only line highlighted as having an error is "Bot->TankDrive(&stickLeft, &stickRight);" C:/WindRiver/workspace/ll/MyRobot.cpp: In member function `virtual void RobotDemo::OperatorControl()': C:/WindRiver/workspace/ll/MyRobot.cpp:38: error: no matching function for call to `RobotDrive::TankDrive(Joystick**, Joystick**)' C:/WindRiver/vxworks-6.3/target/h/WPILib/RobotDrive.h:43: note: candidates are: void RobotDrive::TankDrive(GenericHID*, GenericHID*) C:/WindRiver/vxworks-6.3/target/h/WPILib/RobotDrive.h:44: note: void RobotDrive::TankDrive(GenericHID*, unsigned int, GenericHID*, unsigned int) C:/WindRiver/vxworks-6.3/target/h/WPILib/RobotDrive.h:45: note: void RobotDrive::TankDrive(float, float) C:\WindRiver\vxworks-6.3\host\x86-win32\bin\make.exe: *** [SimpleTemplate_partialImage/Debug/Objects/ll/MyRobot.o] Error 1 Build Failed in Project 'll' (Process Exit Value was 2): 2008-12-18 18:47:20 (Elapsed Time: 00:02) |
|
#2
|
||||
|
||||
|
Re: Pointers and Tank Drive?
Nevermind! I just tried exactly what you said without "&" and ur worked!!! YAY!
![]() |
|
#3
|
|||
|
|||
|
Re: Pointers and Tank Drive?
Quote:
There are two ways of declaring objects: either as an instance of the object or a pointer to the object. In the case of the instance the variable represents the object, and it is created at the time of the declaration. In the case of a pointer you are only creating the space to store the address of the object, but the object remains uncreated. With pointers you have to create the object using the new operator. Look at these two snippets of code to see the difference. Code:
Joystick stick1(1); // this is an instance of a Joystick object called stick1 stick1.GetX(); // instances are dereferenced using the dot (.) operator bot->ArcadeDrive(stick1); // and can be passed to methods as a reference Joystick * stick2; // this is a pointer to an uncreated Joystick object stick2 = new Joystick(1); // this creates the instance of the Joystick object stick2->GetX(); // pointers are dereferenced with the arrow (->) bot->ArcadeDrive(stick2); // and can be passed as pointers (notice, no &) Does this help? Last edited by BradAMiller : 18-12-2008 at 19:28. Reason: improved explanation |
|
#4
|
||||
|
||||
|
Re: Pointers and Tank Drive?
Now i understand the way pointers and instances, etc work!!! Thank you so much!!! and yep! Helps loads! ![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| omni drive vs tank | |20807 61|2|_ | Technical Discussion | 49 | 17-01-2006 13:54 |
| Tank Drive help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | Idaman323 | Programming | 3 | 18-02-2005 15:17 |
| Tank Drive | Idaman323 | Programming | 14 | 15-02-2005 09:01 |
| Swerve/crab drive and tank turning | activemx | Technical Discussion | 9 | 23-02-2004 18:26 |
| tank drive | Stormhammer | Programming | 11 | 29-01-2004 23:08 |