我有以下继承:
Size_(基类)----> Size2_ -------> Size3 _
当我打电话给构造函数时:
Size3_<int> a(2,2,1);
Size3_<int> b(3,3,1);
Size3_<double> c(1,1,0);
Size3_<double> out=(Size3_<double>(b-a))
CPPUNIT_ASSERT(out==c);
我遇到了以下编译器问题(g ++):
SteerableTests.cpp: In member function ‘void SteerableTests::testsize3()’:
SteerableTests.cpp:22:34: error: call of overloaded ‘Size3_(Size3_<int>)’ is ambiguous
SteerableTests.cpp:22:34: note: candidates are:
Size3.h:107:2: note: Size3_<Tp>::Size3_(const cv::Size_<_Tp>&) [with Tp = double]
Size3.h:105:2: note: Size3_<Tp>::Size3_(const Size2_<Tp>&) [with Tp = double]
Size3.h:100:2: note: Size3_<Tp>::Size3_(const Size3_<Tp>&) [with Tp = double, Size3_<Tp> = Size3_<double>]
因此,继承的对象也被视为基础对象。如何告诉g ++编译器选择继承阶段中最低的?在Visual Studio中,它可以工作。
P / S:这是构造函数列表:
Size3_(const Size3_& sz);
Size3_(const Size2_<Tp>& sz2);
Size3_(const Size_<Tp> & cvsz);