HI.. quick implementation question, first off i would like to say im new to the functionality of classes. I understand how they work, however I am having a problem.
What I need to do is read in a string of numbers, seperated by a character...
IE:
3 4 1 2 3 X 4 4 5 3 3 Q 5 5 6 7 3
I have one class:
Code:
private:
int num1,num2,num3,num4,num5;
char letter;
What I need to do is read each group of numbers, and the following symbol
into a sepeart instance of a class...
Thanks in advance for any help !!
IE.
class1 would read in 34123 X
class2 would read in 44533 Q
of each line...... Kind of like an associative array in respect to column numbers each structured as a class..
I just dont know how I can get multiple instances of a class to read in, and continue reading in properly..
IE:
Code:
class c1;
class c2;
class c3;
while(!infile.EOF()) {
c1.readfile(infile); // read first set of nums and char
c2.readfile(infile); // read second set of nums and char
c3.readfile(infile); // read third set of nums;
}
void class::readfile(istream &in) {
in >> num1 >> num2 >> num3 >> num4 >> num5 >> letter;
}
Any help, or explation of how classes work in respect to istreams would be great...
Im trying to have two instances of a class read different parts of a file at different points in the file;...