首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

c++ map使用异常无法理解,求高手

2012-03-17 
c++ map使用错误无法理解,求高手auth.cpp:1886: 错误:从这里auth.cpp:2008: 错误:跳过 ‘std::mapint, int

c++ map使用错误无法理解,求高手
auth.cpp:1886: 错误: 从这里
auth.cpp:2008: 错误: 跳过 ‘std::map<int, int, std::less<int>, std::allocator<std::pair<const int, int> > > a’ 的初始化

先谢谢大家了!



在线等结果

[解决办法]
大哥,这个错误明显是goto引起的。

你在哪里有一个goto mailend

然后gcc说,因为这个goto mailend,所以从这里,跳过了map的初始化,这是错误的。
[解决办法]
作为一个c++标准控,我用c++标准回答你,

c++标准说,goto不可以跳过constructor.

例如,
goto next; //错误,goto不可以跳过int a
int a;
next: a++;

原文:
A program that jumps from a point where a variable with automatic storage duration is not in scope to a point where it is in scope is ill-formed unless the variable has scalar type, class type with a trivial default constructor and a trivial destructor, a cv-qualified version of one of these types, or an array of one of the preceding types and is declared without an initializer (8.5).

热点排行