C++ 程序在编译时崩溃
C++ programme crashes when compiled
这是我编译的 code.After,控制台启动但立即崩溃,提示 name.exe 已停止工作。警告:扩展初始化列表仅适用于 -std=c++11 或 -std=gnu++11。 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\
#include<iostream>
#include<conio.h>
#include<string> //introducing string classes.
struct cia
{
std::string name;
std::string code;
float balance;
};
int main()
{
using namespace std;
cia agent[10] =
{
agent[0] =
{ "wallflower",
"007860",
300000
},
agent[1] =
{
"albus",
"117861",
310000
},
agent[2] =
{
"severus",
"227862",
600000
},
agent[3] =
{
"enigma",
"337862",
550000
},
};
string head="\n\t\t\t\t\tCIA";
string username;
string pass;
cout<<head;
cout<<"\n Welcome To The Most Secure network of Justice.";
cout<<"Username-; ";
cin>>username;
getch();
}
代理定义错误。你应该使用类似的东西:
cia agent[4];
agent[0] =
{ "wallflower",
"007860",
300000
};
agent[1] =
{
"albus",
"117861",
310000
};
agent[2] =
{
"severus",
"227862",
600000
};
agent[3] =
{
"enigma",
"337862",
550000
};
我认为结构应该是这样的:
cia agent[10] = {
{"wallflower", "007860, 300000},
{"albus", "117861", 310000},
... and so on
};
这是我编译的 code.After,控制台启动但立即崩溃,提示 name.exe 已停止工作。警告:扩展初始化列表仅适用于 -std=c++11 或 -std=gnu++11。 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\
#include<iostream>
#include<conio.h>
#include<string> //introducing string classes.
struct cia
{
std::string name;
std::string code;
float balance;
};
int main()
{
using namespace std;
cia agent[10] =
{
agent[0] =
{ "wallflower",
"007860",
300000
},
agent[1] =
{
"albus",
"117861",
310000
},
agent[2] =
{
"severus",
"227862",
600000
},
agent[3] =
{
"enigma",
"337862",
550000
},
};
string head="\n\t\t\t\t\tCIA";
string username;
string pass;
cout<<head;
cout<<"\n Welcome To The Most Secure network of Justice.";
cout<<"Username-; ";
cin>>username;
getch();
}
代理定义错误。你应该使用类似的东西:
cia agent[4];
agent[0] =
{ "wallflower",
"007860",
300000
};
agent[1] =
{
"albus",
"117861",
310000
};
agent[2] =
{
"severus",
"227862",
600000
};
agent[3] =
{
"enigma",
"337862",
550000
};
我认为结构应该是这样的:
cia agent[10] = {
{"wallflower", "007860, 300000},
{"albus", "117861", 310000},
... and so on
};