I have some code where I have used an array to store integer data from a file, sort and print it. I would like to replace the array with the vector class, but it's not as easy as I had hoped. I have a class that I replaced the array with the vector, vector<int> nums;. I have a method where I am opening the data file and reading integers into the vector. I get a compile error:
This is the method:
So, what would be the fix?.
Thanks in advance,
Todd
Code:
error C2228: left of '.push_back' must have class/struct/union type
This is the method:
Code:
void VectorArray::read_scores (void)
{
int temp_num;
nums.resize(n);
infile >> temp_num; // read score in temporary location; prime read
while (!infile.eof() && count < 50) //read no more than 100 numbers
{
if (count = 20)
nums.resize(35); //resize nums vector class from 20 to 35.
nums.at(count).push_back = temp_num;
//scores_ary[count] = temp_num; //store number read in array
count++;
// read next number in temporary location
infile >> temp_num; //next read just before end of while loop
}
}//end read_scores
So, what would be the fix?.
Thanks in advance,
Todd