의 내가이삭제 후 반환 값입니다.
class A {
public:
A(){};
~A(){};
bool foo(int);
};
bool A::foo(int i){
if(i==10){
delete this;
return true;
}
return false;
}
int main(){
A *pnt = new A();
if(pnt->foo(10)){
cout<<"deleted with foo"<<endl;
}
else{
delete pnt;
}
return 1;
}
이 괜찮거나 foo는 사실 돌려 보낼 정의되지 않은 동작하는 클래스를 가지고 가정 해 봅시다?
"delete this;
"다음에 멤버 함수가 어떻게되는지 묻습니다.
http://stackoverflow.com/questions/3150942/c-delete-this – inetknght
Reopened : "중복"은 'void'함수에서'delete this;'에 관한 것입니다. 이 질문은'delete this;'가 괜찮습니까? 'return true;가'delete this;'를 수행 한 후에 OK인지 여부입니다. –
C++ FAQ 항목에서 알 수 있듯이 표준 참조를 볼 수 있습니다. –