|
Hallo!
I try to write a class for legOS in c++.
The constructor should get parameters for the used ports for a motor and
two sensors, which are private components of the class.
Then the contructor should assign these given ports to the private motor
and sensors.
/** Declaration of the class ************************/
class LightSensorHead{
public:
LightSensorHead( const Motor::Port motorport,
const Sensor::Port lsensorport,
const Sensor::Port rsensorport);
...
private:
const Motor motor;
const LightSensor lsensor;
const RotationSensor rsensor;
};
/******* Implementation of the constructor *********/
LightSensorHead::LightSensorHead( const Motor::Port motorport,
const Sensor::Port lsensorport,
const Sensor::Port rsensorport){
motor(motorport);
lsensor(lsensorport);
rsensor(rsensorport);
}
But I have problem to assign the ports in the constructor. The compiler
doesn't want it.
I don't know, what is wrong. It is written like in MotorPair.H from Pat.
I have seperated declaration and implementation, but thats not the
problem.
I tried some versions like:
/**** Declaration ******/
....
private:
const Motor motor(Motor::Port);
With no success.
I use legOS 0.2.5 and gcc 2.95.
Has anyone a tip?
Best regards.
Michael Wisse
|
|
Message has 1 Reply: | | Re: c++, classes
|
| Hi Michael, if you want to use a declarator list in the constructor you have to use the following syntax: /******* Implementation of the constructor ***...***/ LightSensorHead::Lig...ensorHead( const Motor::Port motorport, const Sensor::Port (...) (24 years ago, 5-Apr-01, to lugnet.robotics.rcx.legos)
|
3 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|