Simple C + + problems

Users questions: Run the following program results? classA (public: voidshow () (cout 'A';}}; classB: A (public: voidshow () (cout "B ";}}; voidmain () ( Bb; A * p = &b; p-show ();) The answer is compile-time error, why not do B?
Experts answer:classB: A error. You did not specify inheritance. Corrected output A. I can only say that C + + is such a requirement. If you want it to output B, can it Cl assA in the show () into virtual function. (Virtualvoidshow ())
  • This information provided by the users.Thanks!