Sorry for the vague title. I’m woking on a project that need some knowledge of C++. I don’t learn C++, and don’t have to time to read through a book. So I hope someone is nice enough to give me a start point to look it up.
Here is the code:
TurtlebotTeleop::TurtlebotTeleop(): ph_("~"), linear_(1),angular_(0){
ph_.param("axis_linear", linear_, linear_);
ph_.param("axis_angular", angular_, angular_);
ph_.param("axis_deadman", deadman_axis_, deadman_axis_);
ph_.param("scale_angular", a_scale_, a_scale_);
ph_.param("scale_linear", l_scale_, l_scale_);
}
I know that this chunk of code is defining a method “TurtlebotTeleop”. But What’s those thing after the colon “:”?
Thank you very much for any input.
It is a constructor initialization list. It is syntax for initializing the data members of a class.
The “chunk of code” is the definition of the default constructor of
TurtlebotTeleop. What follows between the:and the{are initializations of some of the data members of that class. Once you get into the body of the constructor (between the{and}) all data members have a value, and whatever you do to them is a change to an existing instance, as opposed to an initialization.