-3

This is my code.After it compiles, the console starts but crashes immediately saying that name.exe has stopped working. warning: extended initializer lists only available with -std=c++11 or -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();


}
Sid 007
  • 3
  • 3

2 Answers2

0

The definition of the agents is wrong. You should use something like:

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

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

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

     agent[3] =
     {
         "enigma",
         "337862",
         550000
     };
Alex P
  • 48
  • 1
  • 1
  • 7
0

I think the struct should be like this:

cia agent[10] = {
    {"wallflower", "007860, 300000},
    {"albus", "117861", 310000},
     ... and so on
};
Devin L.
  • 437
  • 2
  • 12