I am working through some PCL tutorials. In most tutorials the memory for the clouds is allocated dynamically, e.g.:
pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ>);
However, when I try to collect the garbage at the end of the function I get an error message:
error: cannot delete expression of type 'pcl::search::KdTree::Ptr' (aka 'shared_ptr > > >') delete tree;
My confusion boils down to this:
- Am I misinterpreting the declaration of the
tree
variable? - What is the meaning of the
<type*> <variableName> (new <type>)
expression? Does this not create a pointer and allocate new memory on the heap? - How would I go about collecting the garbage correctly?
Maybe somebody can shed some light onto this for me. Many thanks in advance!