我有一個通用的清單與模板 template<class t>
class GenericList {
//the data is storeed in a chained list, this is not really important.
struct c_list { t data; c_list* next; ...constructor... };
public
我編譯&運行下面粘貼的代碼,令人驚訝的是它工作沒有錯誤。 (g ++/linux) 如何刪除的對象有一些成員仍然可用?這是一種正常的行爲嗎? #include <iostream>
using namespace std;
class chair {
public:
int height;
int x;
int y;
chair() {
如何從淺拷貝對象vs原始對象中刪除雙(刪除)錯誤。 一個簡單的例子: class INT
{
int *p; //dynamic.
//define here fancy constructors etc.
set(int i){ p=new int; p=i;}
~INT();
}
INT::~INT()
{
if(p) delete