I am having a problem creating a vector of type struct. this is my code that will not work:
[code=cpp]
//Initialization steps prior to code.
#include <iostream>
#include <vector>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
int main ()
{
char letter;
int numb = 0;
struct acct
{
char first [15];
char last [15];
char ssn [9];
char logon [8];
};
vector <acct> accounts;
ifstream roster; //These lines initialize the text file containing the account data.
roster.open("/roster.txt");
if (roster.fail()) return 1;
[/code]
the error msg is:
error: 'main()::acct' uses local type 'main()::acct'
error: trying to instantiate 'template<class _Alloc> class std::allocator'
error: template argument 2 is invalid
error: invalid type in declaration before ';' token
[code=cpp]
//Initialization steps prior to code.
#include <iostream>
#include <vector>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
int main ()
{
char letter;
int numb = 0;
struct acct
{
char first [15];
char last [15];
char ssn [9];
char logon [8];
};
vector <acct> accounts;
ifstream roster; //These lines initialize the text file containing the account data.
roster.open("/roster.txt");
if (roster.fail()) return 1;
[/code]
the error msg is:
error: 'main()::acct' uses local type 'main()::acct'
error: trying to instantiate 'template<class _Alloc> class std::allocator'
error: template argument 2 is invalid
error: invalid type in declaration before ';' token
Comment