Quote:
Originally Posted by xraymypanda
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.