I need help to understand well the use of struct
I have this snippet of code:
struct PCD
{
PointCloud::Ptr cloud;
std::string f_name;
PCD() : cloud (new PointCloud) {};
};
But I don't understand how is possible this row:
PCD() : cloud (new PointCloud) {};
or better, what does it do? A struct
in the struct
?
Where could I find a good explanation of it?
cloud
is a pointer to a PointCloud
object. It's a member of the PCD
struct. When this struct is initialized using the initializer list, that pointer is allocated a new PointCloud
object.
This is likely found in the PointCloud
struct/class:
typedef PointCloud* Ptr;
PCD() : cloud (new PointCloud) {};
is a PCD constructor that initializes the cloud variable with a new PointCloud instance.
struct PCD
{
PointCloud::Ptr cloud;
std::string f_name;
PCD() : cloud (new PointCloud) {};
};
can be rewritten and visualized as:
struct PCD
{
public:
PointCloud::Ptr cloud;
std::string f_name;
PCD();
};
PCD::PCD() : cloud (new PointCloud) {};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With