指針釋放出現(xiàn)問題,計算面積的方法沒有被調(diào)用
deleting object of polymorphic class type 'shape' which has non-virtual destructor might cause undefined behavior [-Wdelete-non-virtual-dtor]
shape?*p1?=?new?circle(3.2); shape?*p2?=?new?rect(4.6,5.2); p1->jsmj(); p2->jsmj(); delete?p1 p1?=?NULL; delete?p2; p2?=?NULL; return?0;
2019-10-12
就是叫你在shape類定義一個虛析構(gòu)函數(shù),不然rect和circle的析構(gòu)函數(shù)不會執(zhí)行
2019-10-07
能發(fā)完么,這么點代碼,并不能看出問題