help on some vector of custom class code

This is a discussion on help on some vector of custom class code within the C++ Programming forums, part of the General Programming Boards category; vector<BPage> Book; int numEntries; void Load(string filename) { ifstream lfile(filename.c_str()); if(!lfile) { exit(1); } BPage tpage; string tfname, toname, tlname, ...

  1. #1
    cozman
    Guest

    Unhappy help on some vector of custom class code

    vector<BPage> Book;
    int numEntries;

    void Load(string filename)
    {
    ifstream lfile(filename.c_str());
    if(!lfile)
    {
    exit(1);
    }

    BPage tpage;
    string tfname, toname, tlname, tnum, temail, tother, junk;

    lfile >> numEntries; //get the number of entries in the file

    for(int i = 0; i < numEntries; i++)
    {
    lfile >> tfname >> toname >> tlname >> tnum >> temail >> tother >> junk;
    tpage.SetName(tfname, toname, tlname);
    tpage.SetNumber(tnum);
    tpage.SetEmail(temail);
    tpage.SetOther(tother);

    Book[i] = tpage;
    }
    }

  2. #2
    cozman
    Guest

    -

    no need to answer the line in question should have read Book.push_back(tpage);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with FIFO QUEUE
    By jackfraust in forum C++ Programming
    Replies: 23
    Last Post: 04-03-2009, 09:17 AM
  2. Class design problem
    By h3ro in forum C++ Programming
    Replies: 10
    Last Post: 12-19-2008, 09:10 AM
  3. Default class template problem
    By Elysia in forum C++ Programming
    Replies: 5
    Last Post: 07-11-2008, 09:44 AM
  4. My Window Class
    By Epo in forum Game Programming
    Replies: 2
    Last Post: 07-10-2005, 03:33 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21