View Single Post
  #10   Spotlight this post!  
Unread 17-12-2011, 16:28
WizenedEE's Avatar
WizenedEE WizenedEE is offline
Registered User
AKA: Adam
FRC #3238 (Cyborg Ferrets)
Team Role: Leadership
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Anacortes, WA
Posts: 395
WizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to all
Re: Team 599 Robodox - 2011 Logomotion Code

Quote:
Originally Posted by xraymypanda View Post
If I recall correctly, pointers are constructed when the code is first called then destructed when they are no longer needed.
Objects allocated with new are only destructed when delete is called on them. Statically allocated objects act essentially this way, though.

Quote:
The code is called upon three times, once when the robot first turns on, when autonomous begins, and finally when the tele-op period begins.
The constructor? That's only called when FRC_UserProgram_StartupLibraryInit() is called (defined in the START_ROBOT_CLASS macro) and never again.

Quote:
With pointers, the values of the variables are reset to their original position because a new copy is constructed for autonomous and a new copy is constructed for teleop.
I'm not sure what you mean by this. The copy constructor is disabled in SensorBase, which is inherited by all of the sensor classes, and new is only called in your class's constructor.

Quote:
Otherwise, as with an object, when tele-op begins, the state that the sensor was last left in will now be its zero state. This could cause problems with an automatic lift system using an encoder or with gyroscopes on the robot.
Do you have a source for that? I didn't think there was any difference between dynamically and statically allocated objects functionally.
Reply With Quote