Push_back not storing data to vector
For some reason my vector doesn't push_back data (or accept data)
Code:
class Fleet
{
private:
typedef vector<Car> CarFleet;
typedef CarFleet::iterator FleetIterator;
public:
Fleet();
void ReadFleetFromFile();
private:
CarFleet fleet;
};
Code:
void Fleet::ReadFleetFromFile()
{
char filename[MAX_PATH] ;
puts("\n\nPlease enter the text file to open:\n");
cin >> filename;
ifstream fleetin;
fleetin.open (filename);
/* Ensure file was opened, otherwise send an error */
if ( fleetin.fail() )
{
puts("");
perror("ERROR! while trying to open file");
exit(1);
}
else
{
// Read number of records from file
while (!fleetin.eof())
{
Car car;
if( car.Read(fleetin) )
fleet.push_back(car); // After this line car contains data, but fleet doesn't
}
puts("\nProcessed reading...");
}
fleetin.close();
}
I used a debug (F5) and a break point at fleet.push_back(car) ... Car does contain data read from file, after executing this line, by using VS2005 watch window on fleet, i just see {_Myfirst='some address' _Mylast='address' Myend='address again'} ... An when i expoand the plus sign on fleet watch window to check elements, there are 'error' with 0 values... Completely lost here