【发布时间】:2013-10-15 01:57:19
【问题描述】:
template<class CharType>
struct MyString
{
MyString()
{}
MyString(CharType*)
{}
};
int main()
{
char* narrow_str = 0;
MyString<char>(narrow_str); // error C2040
}
我的编译器是 VC++ 2013 RC。
最简单的代码无法编译,因为错误C2040。
错误 C2040:“narrow_str”:“MyString”的级别不同 间接来自 'char *'
为什么?
【问题讨论】:
-
你认为的构造函数调用其实不是
标签: c++ templates compiler-errors temporary-objects type-deduction