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' '行方不明]必要とされる前に必要とされる名前に依存しない名前b) – dhke
関数の外で 'f =&s; 'を実行しようとしていますか? – aschepler
通常、コンパイラがクラスを見つけることができないときにこのエラーが出ます。fを抽象クラスとして持っているのは私にとっては非常に普通です。問題はインクルードにあると思います。正しい場所? –