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

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

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

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_;

........
.......

public:
 ImageConverter()
    : 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
2

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

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

Comments

Oh okay. Now I get it. Thank You.

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

Question Tools

1 follower

Stats

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

Seen: 193 times

Last updated: Aug 10 '16