one question about operator delete# Programming - 葵花宝典
x*h
1 楼
Hi, I have a question about operator delete, dtor.
define a class like below,
class TestDelete{
public:
virtual ~TestDelete(){
std::cout << "TestDelete::~TestDelete" << std::endl;
}
void operator delete (void* p){
std::cout << "TestDelete::operator delete()" << std::endl;
}
// void operator delete[] (void* p){
// std::cout << "TestDelete::operator delete()" << std::endl;
// }
};
then, write statements like :
TestDelete* p = NULL;
delete p;
I found
define a class like below,
class TestDelete{
public:
virtual ~TestDelete(){
std::cout << "TestDelete::~TestDelete" << std::endl;
}
void operator delete (void* p){
std::cout << "TestDelete::operator delete()" << std::endl;
}
// void operator delete[] (void* p){
// std::cout << "TestDelete::operator delete()" << std::endl;
// }
};
then, write statements like :
TestDelete* p = NULL;
delete p;
I found