ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Can anyone give a better understanding of this piece of code? [closed]

asked 2016-08-10 12:48:17 -0600

skr_robo gravatar image

I have a question regarding the following lines in the node given here :

class ImageConverter
  ros::NodeHandle nh_;
  image_transport::ImageTransport it_;


    : it_(nh_)

I know that the constructor is assigning the value of nh_ to it_, but are they not variables of different type? If they are not, how can we know that?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by skr_robo
close date 2016-08-10 13:44:31.546603

1 Answer

Sort by ยป oldest newest most voted

answered 2016-08-10 13:11:01 -0600

ahendrix gravatar image

The constructor is not assigning to it_; it's invoking the constructor for it_ and passing nh_ as the argument to that constructor.

In general, the C++ initializer list syntax calls the constructor for each item. (and for scalar types construction is the same as assignment)

edit flag offensive delete link more


Oh okay. Now I get it. Thank You.

skr_robo gravatar image skr_robo  ( 2016-08-10 13:44:13 -0600 )edit

Question Tools

1 follower


Asked: 2016-08-10 12:48:17 -0600

Seen: 189 times

Last updated: Aug 10 '16