0

Dear c++ gurus, i have thk all over wat is means by the following hightlighted text, but not understood, can anyone explain to me what do they mean? or how do they function?

class RotationSensor : public Sensor {
public:
RotationSensor(const Port port, int position = 0)
    : Sensor((Sensor::Port) port, true), 
    rsensor((port == S1) ? ROTATION_1 :
	    (port == S2) ? ROTATION_2 :
	    ROTATION_3)
#ifdef CONF_DSENSOR_VELOCITY
    ,
    rvelocity((port == S1) ? VELOCITY_1 :
	      (port == S2) ? VELOCITY_2 :
	      VELOCITY_3)
#endif // CONF_DSENSOR_VELOCITY
  {
    on();          //! Turn on tracking of the sensor
    pos(position); //! Set the current position
  }
..........................................................
}

Thanks guru.

Votes + Comments
Equalizing the incorrectly handed positive reputation.
Thanks for using code tags correctly :)
2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Suraine
0

>>the following hightlighted text
There are no highlishted text. Do you mean lines 5, 6 and 7 ? That is doing the same thing as if there were a series of if statements, like this:

if( port == S1)
    rsensor = ROTATION_1;
else if( port == S2)
    rsensor = ROTATION_2;
else
    rsensor = ROTATION_3;
0

Thanks, guru Ancient Dragon.

Good to know that what i have been guessing is correct.
therefore the same apply for:

rvelocity((port == S1) ? VELOCITY_1 :   
              (port == S2) ? VELOCITY_2 :         
               VELOCITY_3)

ya, im much more confident now, thanks.

The next question is, for:

RotationSensor(...) : Sensor (...), rsensor(...), rvelocity(...)
{
          on();
          pos(position);
}

wat does this block of codes represent? or do? or how it function?

thanks again guru.

Edited by mike_2000_17: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.