0
나는 Point Cloud Library 함께 일하고 있어요 그리고 난 다음 동작을 반복하지 않도록하기 위해 노력하고있어 :추상 유형의 C++ 포인터를 사용하여 구체적인 클래스를 가리키는 방법은 무엇입니까?
pcl::PointCloud<pcl::PointXYZRGB>::Ptr filter(PointCloud<pcl::PointXYZRGB>::Ptr input_cloud) {
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_filtered(new pcl::PointCloud<pcl::PointXYZRGB>);
subclass.setInputCloud(input_cloud);
subclass.filter(*cloud_filtered);
return cloud_filtered;
}
나는이 example를 기반으로 뭔가를 사용하기를 희망하고의 라인을 따라 :
pcl::Filter<PointXYZRGB>* f;
pcl::Subclass<PointXYZRGB> s; //where s is an implementation of f
f = &s;
pcl::PointCloud<pcl::PointXYZRGB>::Ptr filter(PointCloud<pcl::PointXYZRGB>::Ptr input_cloud) {
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_filtered(new pcl::PointCloud<pcl::PointXYZRGB>);
f->setInputCloud(input_cloud);
f->filter(*cloud_filtered);
return cloud_filtered;
}
그러나이 컴파일러에 의해보고 된 f does not name a type
같이 컴파일되지 않습니다.
pcl::Filter이 추상 클래스이기 때문에 이것이라고 생각하십니까?
이 접근법은 pcl::VoxelGrid과 같은 예제 클래스에 유효합니까 아니면 대안이 있습니까?
도움이되었습니다.
(http://stackoverflow.com/questions/8584431/why-is-the-keyword-typename- ['typename' 실종]를 required-before-qualified-dependent-names-and-not-b) – dhke
함수 외부에서'f = & s; – aschepler
컴파일러가 클래스를 찾을 수 없을 때 보통이 오류가 발생합니다. f가 내게있는 추상 클래스로 f를 가지는 것이 정상입니다. 문제가 include 또는 something에 있다고 생각합니다. 포함 할 것이 확실합니다. 바른 장소? –