c ++ ros message_filters class is instantiated three ways

Examples of the class into the class of non-instantiated

Examples of non-class
manner. 1
message_filters for Subscriber :: <sensor_msgs :: CompressedImage> image_sub;
image_sub (NH_, cam1_topic_name,. 1);

方式2
message_filters::Subscriber<sensor_msgs::CompressedImage> image_sub;
image_sub.subscribe(nh_, cam1_topic_name, 1);

方式3
message_filters::Subscriber<sensor_msgs::CompressedImage> image_sub*;
image_sub = new message_filters::Subscriber<sensor_msgs::CompressedImage>(nh_, cam1_topic_name, 1);

Instantiate the class
only different from Embodiment 2
Embodiment 2
calss A {
public:
    A () {
    }
public:
    message_filters for Subscriber :: <sensor_msgs :: CompressedImage> image_sub;
}
need to be concerned image_sub be instantiated where?
How to define a class there are another object class constructor parameter?
refer https://blog.csdn.net/syb1295306116/article/details/80896306
create image_sub this object is a member at the time of execution of the constructor a constructor of a image_sub later have to provide for the initialization table object members in the form of, for example a (): image_sub (nh_, cam1_topic_name, 1) {} If no parameter is image_sub in the constructor, an error will occur.
All object classes are defined (including basic types of data objects, class objects with no parameters, etc.) are carried out in a configuration such initialization list, but no reference objects and primitives are omitted. The so-called initialization in the constructor body, but to the object that has been generated reassigned fills constructed object and no. That object constructor must initialize the list. This means that the construction of other class objects prior to the construction of this class.

Guess you like

Origin blog.csdn.net/chengde6896383/article/details/90903527