OK, sorry for cluttering up the LC thread, if anyone can help me in my struggles to learn C++ I would be much obliged.
So, the function below is a function of the Airline has as its input a pointer to the Flight class. Airline has two data fields, ptrFlights, an array of pointers to Flight objects, and numberFlights, a running tally keeping track of how many Flight objects have been added to the ptrFlights array.
So my problem is with lines 42-46. All the cout lines are just me trying to keep track of what is going on, the else statement is just the bolded two lines:
cout << numberFlights << endl;
ptrFlights[numberFlights]=newFlight;
cout << numberFlights << endl;
numberFlights=numberFlights+1;
cout << numberFlights << endl;
When I run the code the output of this is something like this. The huge number is always different, then incremented by one
0
1360869592
1360869593
WTF? isn't line 43 me taking the numberFlights element of ptrFlights and assigning it to newFlight? How is it assigning numberFlights some huge value when I do that?
Last edited by SenorKeeed; 04-11-2013 at 01:36 PM.