I'm having some real problem with a list of objects. My objects in this case are called Aircraft & I've given them these features:
int flightNo;
void setFlightNo(int i)
{
flightNo = i;
}
int getFlightNo()
{
return flightNo;
}
Ok, all good - until I put them in a list - list<Aircraft> landed.
I've tried several implementations including
1) Have the list as a variable of the main.cpp file
2) Write a wrapper class for the list
2i) Have main generate new aircraft & pass by value to wrapper class to add to list
2ii) Have wrapper class create new aircraft itself & add to list
No success so far. Before I put the aircraft in the list
cout << aircraft.getFlightNo()
always shows the correct value. After pushing, aircraft into landed
cout << landed.front.getFlightNo()
, or a wrapper class serving an Aircraft object using the getFlightNo method gives me either 0 or a very large number usually starting with 3.
I don't know if this is relevant but the method for generating the aircraft & adding it to the list is being called from a pthread.
Any assistance would be greatly appreciated!