To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 1824
1823  |  1825
Subject: 
Re: c++, classes
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Thu, 5 Apr 2001 07:52:48 GMT
Viewed: 
1392 times
  
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::LightSensorHead( const Motor::Port motorport,
                                   const Sensor::Port lsensorport,
   const Sensor::Port rsensorport)
: motor(motorport),  lsensor(lsensorport),  rsensor(rsensorport)
{
}

Hope this helps.

Best Regards
Frank



Message has 1 Reply:
  Re: c++, classes
 
Hallo Frank, yes, it helped, thanks. But I still don't understand the background. Normally, in c++ you can initialize your private components in the body of the constructor or with a initialization list, like in your suggestion. Reagards. Michael (...) (24 years ago, 10-Apr-01, to lugnet.robotics.rcx.legos)

Message is in Reply To:
  c++, classes
 
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 (...) (24 years ago, 4-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

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR