I am writing a point cloud class with several features. I wanted to implement some specific function for only 3 dimensional point clouds. Therefore I implemented the general class hierarchy in the following way in which I partially specialize one of the template arguments for the point cloud (using Eigen as the linear algebra library):
template <typename T, unsigned int DIM>
class PointCloudBase {
public:
using Vector = Eigen::Matrix<T, DIM, 1>;
using Hyperplane = Eigen::Hyperplane<T, DIM>;
using MatrixDIM = Eigen::Matrix<T, DIM, DIM>;
using AlignedBox = Eigen::AlignedBox<T, DIM>;
bool convexHullIntersects(const AlignedBox& box) const {
// generic implementation for this function
}
// more stuff here
};
template<typename T, unsigned int DIM>
class PointCloud : public PointCloudBase<T, DIM> {
};
template<typename T>
class PointCloud<T, 3U> : public PointCloudBase<T, 3U> {
public:
using typename PointCloudBase<T, 3U>::AlignedBox;
using typename PointCloudBase<T, 3U>::Vector;
bool convexHullIntersects(const AlignedBox& box) const override {
// implementation specific to DIM = 3U
}
};
However when I try to instantiate the class as PointCloud<double, 3U> pc;
, I get the following error that complains that convexHullIntersection is not overriding anything:
error: ‘bool PointCloud<T, 3>::convexHullIntersects(const typename PointCloudBase<T, 3>::AlignedBox&) const [with T = double; typename PointCloudBase<T, 3>::AlignedBox = Eigen::AlignedBox<double, 3>]’ marked ‘override’, but does not override
What can be the problem here?
Thanks!
Aucun commentaire:
Enregistrer un commentaire