Quote:
Originally Posted by daltore
Basically, constructor is the equivalent of Initialize() or IO_Initialization() of the PIC version of WPILib, except I think it runs more than once.
|
A constructor is a standard C++ language feature, and constructor only gets called once per created object, and only when the object is instantiated (for example, if you do a "new ObjectName()" then a new object is created and a constructor is called.. of course there are other ways to create an object also).
If you examine WPILib, the START_ROBOT_CLASS macro passes startRobotTask() a function that creates an object of your RobotBase derived class. Once it starts the robot task, it creates your object. This is only done once (or at least, only when FRC_UserProgram_StartupLibraryInit() is called).
Strictly speaking, FRC_UserProgram_StartupLibraryInit (also defined in the START_ROBOT_CLASS macro) is more like Initialize() or IO_Initialization()... but of course it gets called before your task is created and its probably not a particularly great idea to use it.
