64,654
社区成员
发帖
与我相关
我的任务
分享
#include <string>
using namespace std;
int main()
{
goto YES;
string s;
YES:
return 0;
}
如果将string改为char或者int,均可以编译通过
但是使用string、set、map等,编译不过:g++ main.cpp -o run
main.cpp: In function `int main()':
main.cpp:7: error: jump to label `YES'
main.cpp:5: error: from here
main.cpp:6: error: crosses initialization of `std::string s'
编译器:
gcc version 3.4.6 20060404 (Red Hat 3.4.6-3)
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s;
goto YES;
cout<<s;
YES:
return 0;
}
//如果是这样的话,就不会错了;看来还是s初始化的问题;