Template Problem
-
Hallo Leute, ich möchte meine methode
void a( pcl::PointCloud<pcl::PointXYZ>::Ptr &b , const pcl::PointIndices::Ptr &c ) const { //... }in ein Template umwandeln, welches so aussieht:
template<typename T> void a( pcl::PointCloud<T>::Ptr &b , const pcl::PointIndices::Ptr &c ) const { //... }Bekomme aber beim Kompilieren, ohne dass ich irgendwoe dieses Template nutze einen Fehler:
`error C2065: 'b' uncleared identifier
`
Wo liegt mein Fehler?
-
asdsaddsaas schrieb:
template<typename T> void a( pcl::PointCloud<T>::Ptr &b , const pcl::PointIndices::Ptr &c ) const { //... }Bekomme aber beim Kompilieren, ohne dass ich irgendwoe dieses Template nutze einen Fehler:
`error C2065: 'b' uncleared identifier
`
template<typename T> void a( typename pcl::PointCloud<T>::Ptr &b , const pcl::PointIndices::Ptr &c ) const { //... }
-
Da fehlt ein
typename. Die Signatur sollte lauten:template<typename T> void a( typename pcl::PointCloud<T>::Ptr &b , const pcl::PointIndices::Ptr &c ) const { //... }Grund ist, dass der Compiler nicht entscheiden kann, ob pcl::PointCloud<T>::Ptr ein Typ oder eine Konstante oder eine statische Variable oder irgend etwas anderes ist. Daher musst du mit typename explizit sagen, dass es sich um einen Typen handelt.
-
-
Supi! Danke für die Hinweise.