0
超载赋值运算符,我需要一份简历::垫分配给CV ::三维点C++库类
cv::Point3d pt;
cv::Mat mat(3, 1, CV_64F);
pt = mat;
我试图做到这一点在两种不同的方式。第一次尝试如下:
template<typename _Tp>
inline cv::Point3_<_Tp> & cv::Point3_<_Tp>::operator = (const cv::Mat & mat){ ... }
,但它提供了以下编译错误:
Out-of-line definition of 'operator=' does not match any declaration in 'Point3_<_Tp>'
我也试过这种不同的解决方案:
template<typename _Tp>
inline cv::Mat::operator cv::Point3_<_Tp>() const { }
然而,编译器不喜欢它,并提供以下错误:
Out-of-line definition of 'operator Point3_<type-parameter-0-0>' does not match any declaration in 'cv::Mat'
我缺少什么?
为什么不只是制作一个免费的函数'cv :: Point3d create_point(cv :: Mat const&mat)'?然后你可以说'cv :: Point3d pt = create_point(mat);' – CoryKramer
因为我更喜欢避免将显式调用函数作为create_point() – thewoz