64,649
社区成员
发帖
与我相关
我的任务
分享
template<typename T>
class Number
{
public:
Number(T val)
{
m_value = val;
}
T GetVal()
{
return m_value;
}
private:
T m_value;
};
class Integer: public Number<int>
{
};
int _tmain(int argc, _TCHAR* argv[])
{
Integer i(5);
return 0;
}
1>------ Build started: Project: test, Configuration: Debug Win32 ------
1>Compiling...
1>test.cpp
1>d:\my\code\fvck\dlib\test\test.cpp(32) : error C2664: 'Integer::Integer' : cannot convert parameter 1 from 'int' to 'const Integer &'
1> Reason: cannot convert from 'int' to 'const Integer'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1>Build log was saved at "file://d:\my\code\fvck\dlib\test\Debug\BuildLog.htm"
1>test - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
class Integer: public Number<int>
{
public:
Integer(int i): Number<int>(i){}
};