Learning from a mistake that was corrected in this very forum, I am trying to pass parameters into my class constructors CORRECTLY.
For example, here in the Train class, I am passing my CTrainLine object using the address operator & so that the constructor does not make a temporary copy. Before that fix, I was having all kinds of errors I had no idea where they were coming from.
Trying not to make the same mistake twice, I copied the exact same method to pass in my PassengerManager object. However when I do this, I get the following error:
32 non-static reference member `CTrainLine&PassengerManager::redLine', can't use default assignment operator
Can someone tell me why it's giving me this error when CTrainLine passed in just fine?
You already have it in the initialization list. Line 31 above is effectively redundant which means that you can remove it without any problems.
I assume that the reason why it didn't work was that you hadn't defined: CTrainLine CTrainLine::operator= (const CTrainLine& rhs);
Since this class likely contains pointers, it will not copy the data with a default function.
If that is the case, then make sure that you also define a copy constructor, or you'll run into problems with the initialization as well.