What is output by the following program:
# Include <iostream> using namespace STD; Class A {public: void virtual F () {cout <"A" <Endl ;}}; Class B: public A {public: void virtual F () {cout <"B" <Endl ;}}; int main () {A * pA = new (); // defines a pointer Pa of type A. Pa points to Class A pa-> F (); B * pb = (B *) Pa; // defines a pointer of type B, Pb also points to type a Pb-> F (); Delete Pa, PB; // deletes the addresses pointed to by PA and Pb, however, the pointer type of PA and Pb is still the PA of Class A = new B (); // PA points to Class B pa-> F (); Pb = (B *) Pa; pb-> F (); Return 0 ;}
This topic mainly deals with the problem of overwriting virtual functions. Virtual functions are covered by functions with the same name in the quilt class.
The output result is AABB.
This article is from the "7883538" blog, please be sure to keep this source http://7893538.blog.51cto.com/7883538/1433391