You'll also need to make a non const point cloud to store the result. Whenever you see a const type in C++ it means that its value cannot be changed. So you'll need to define a variable like sensor_msgs::PointCloud2 p_output_pointcloud_ptr; for the result.