编译时C ++程序崩溃

时间:2017-07-31 18:28:09

标签: c++ c++11 codelite

这是我的代码。编译完成后,控制台启动但立即崩溃,说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();


}

2 个答案:

答案 0 :(得分:0)

代理商的定义是错误的。你应该使用类似的东西:

    cia agent[4];
     agent[0] =
     {    "wallflower",
         "007860",
         300000
     };

     agent[1] =
     {
         "albus",
         "117861",
         310000
     };

     agent[2] =
     {
         "severus",
         "227862",
         600000
     };

     agent[3] =
     {
         "enigma",
         "337862",
         550000
     };

答案 1 :(得分:0)

我认为结构应该是这样的:

eval