Thread: I need help..anything will be appreciated

  1. #1
    Unregistered
    Guest

    Lightbulb I need help..anything will be appreciated

    I need to enter information into a vector inside a class...here it goes--


    class aStudent
    {
    public:

    string names;
    vector <int> scores;
    double average;
    char grade;
    };

    and when I call this class--

    void (istream infile, vector<aStudent> classList)

    aStudent student;

    infile(input from a file -- student.dat) >> student.name >> ????

    how do I import this information into this vector inside this class...I know its no too hard but I cant find it anywhere... once again...anything will be very appreciated...thx in advance

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    student.scores[0]=0;

    something like that?
    Last edited by Stoned_Coder; 12-02-2001 at 06:57 AM.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Unregistered
    Guest
    Thx for reply...I tried that but it didnt work???...anything else...once again thx u!!!

  4. #4
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    If you're not initialising the vector with a size then you can use -

    student.scores.push_back(score);

    to dynamically add items to a vector.
    zen

  5. #5
    Unregistered
    Guest
    thx Zen...no the vector doesnt want to get initialized at all...i giving me an error...const vector...if you take out the size it goes away...Im gonna try yours to c if it works...and THX A LOT BUD...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Control, HELP appreciated.
    By Astra in forum Windows Programming
    Replies: 7
    Last Post: 01-01-2007, 06:59 AM
  2. Linker Errors, Help Appreciated
    By burntheart in forum Windows Programming
    Replies: 3
    Last Post: 03-27-2006, 07:13 AM
  3. Help Appreciated
    By cboard_member in forum C++ Programming
    Replies: 10
    Last Post: 08-02-2005, 06:31 AM
  4. Simple question. Help will be appreciated.
    By wickedclownz in forum C++ Programming
    Replies: 2
    Last Post: 06-19-2003, 02:18 AM
  5. C++ Programs -- Any input appreciated
    By Kyoto Oshiro in forum Game Programming
    Replies: 0
    Last Post: 02-27-2002, 11:22 PM