奇妙な問題が発生しました。クラスメソッド内で削除演算子を使用していますが、この問題を解決する方法を知りたいです。
これはコードです:
#include <iostream>
using namespace std;
class A
{
public:
int a;
~A() {
cout << "call ~A()" << endl;
}
void action()
{
/* code here */
delete this; //this line depends on some if statements
/* code here */
}
void test2() {
cout << "call test2()" << a << endl;
}
void test() {
a = 10;
cout << "call test()" << endl;
action();
//how can I check if data is deleted?
test2();
}
};
int main()
{
A* a = new A();
a->test();
}
delete operator によってデータが削除されたかどうかを確認するにはどうすればよいですか? それは可能ですか?