Virtual inherited class instance DELETE exception

xiaoxiao2021-03-06  66

This question code: #include using namespace std;

Class base {public: base () {cout << "base" << endl;} ~ base () {cout << "~ base" << endl;}};

Class Derive: Virtual Public Base {public: derive () {cout << "derive" << endl;} ~ derive () {cout << "~ derive" << endl;}};

INT Main (int Argc, char * argv []) {base * b = new deerive (); delete b; return 0;} The above delete will lead to an access exception (VC6.0). If the main function is changed to: Derive * b = new deer (); delete b; return 0; will not have any abnormal appearance.

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

New Post(0)