Not a major issue, just annoying as I don't want my class to ever be instantiated without the particular arguments.
#include <map>
struct MyClass
{
MyClass(int t);
};
int main() {
std::map<int, MyClass> myMap;
myMap[14] = MyClass(42);
}
这给出了下面的 g + + 错误:
/usr/include/c + +/4.3/bits/stl _ map. h: 419: error: no match function for call to‘ MyClass ()’
如果我添加一个缺省构造函数,这样编译就很好了,我确信这不是由于语法不正确造成的。