|"What I did was I created two constructors for Passenger: one that takes an argument and one that doesn't. For some reason when I do this, I don't get the qNode error."|
I'm assuming you added the default constructor (the constructor with no formal parameters) after the conversion constructor (the constructor with a single formal parameter)?
" had a "Passenger
" data-member, "qNode
"'s default constructor (called when you attempted to allocate a new "qNode
") attempted to construct the "qNode::data
" data-member. But because you overloaded the default constructor of "Passenger
", the compiler was not able to call "qNode::data
"'s default constructor so it had no choice but to call the conversion constructor, but that soon failed because it needed an actual parameter to be passed to it*. By explicitly declaring a default constructor for "Passenger
", the compiler was able to make the call to the default constructor of "qNode::data
" in order to construct the object.
*A compiler cannot assume the value of an actual parameter unless an actual parameter is specified as a default. Therefore, it cannot call a function unless either all formal parameters are given actual parameters by the calling function or all formal parameters have default actual parameters.