pcl PointCloud Ptr非成员变量时可以直接在声明中初始化pcl::PointCloud<PointType>::Ptr p(new pcl::PointCloud<PointType>());
1. 作为类成员变量时,需要额外的初始化。可以在构造函数初始化列表中初始化或者构造函数内初始化。
class A{
public:
A();
pcl::PointCloud<PointType>::Ptr p;
}
A::A()
:p(new pcl::PointCloud<PointType>())
{
}
class A{
public:
A();
pcl::PointCloud<PointType>::Ptr p;
}
A::A()
{
p = pcl::PointCloud<PointType>::Ptr(new pcl::PointCloud<PointType>());
}
2.作为结构体成员变量时,使用reset进行初始化
struct MyStruct
{
pcl::PointCloud<PointType>::Ptr p;
}
MyStruct test;
test.p.reset(new pcl::PointCloud<PointType>());