A fun problem

xiaoxiao2021-03-06  61

Struct a {

Void Kk () {Printf ("a / n");}}; struct b {void kk () {printf ("b / n");}};

INT Main (int Argc, char * argv []) {a * a = new a; b * b = new b; A = (a *) b; A-> kk (); return 0;} output A // / STRUCT P {Virtual Void KK () = 0;

Struct A: public p {

Void KK () {Printf ("a / n");}}; struct b: public p {void kk () {printf ("b / n");}};

INT Main (int Argc, char * argv []) {a * a = new a; b * b = new b; A = (a *) b; A-> kk (); return 0;} Output bwhy?

转载请注明原文地址:https://www.9cbs.com/read-113677.html

New Post(0)