self-destruction
delete this ? what does it do?
Given the following : #include <iostream> using namespace std; class A { public: void func() {delete this;}[详细]
2023-03-31 19:59 分类:问答Is it valid to directly call a (virtual) destructor?
In this answer, Ryan directly calls the virtual destructor. I\'ve tested the code in VS2010, and it correctly calls all destructors (tested with logging statements). Is it actually valid to do so? Wha[详细]
2023-03-06 19:22 分类:问答"delete this" in constructor
What开发者_如何学运维 actually happen when I execute this code? class MyClass { MyClass() { //do something[详细]
2023-02-17 06:12 分类:问答Suicide: Objective-C objects calling their own -dealloc methods on themselves
Is it good practice for an object in Objective-C to commit suicide? That is, for an object to declare [self dealloc] where -dealloc permits an orderly wind down as usual? What are the principal risks?[详细]
2023-01-17 20:55 分类:问答Is "delete this" allowed in C++?
Is it allowed to delete this; if the delete-statement is the last statement that will be executed on that instance of the class? Of course I\'m sure that the object represented by the this-pointer is[详细]
2023-01-05 11:17 分类:问答PHP file that should run once and delete itself. Is it possible?
Is it possible to create a 开发者_运维知识库PHP file that runs once with no errors and deletes itself?<?php unlink(__FILE__); ?>[详细]
2022-12-25 22:17 分类:问答Should "delete this" be called from within a member method?
I was just reading this article and wanted SO folks advice: Q: Should delete this; be call开发者_如何学JAVAed from within a member method?Normally this is a bad idea, but it\'s occasionally useful.[详细]
2022-12-13 21:54 分类:问答Can I delete a dynamically allocated class using a function within that class?
I\'m writing a state manager for a game. I\'ve got most of the logic down for how I want to do this. I want states, which will be classes, to be handled in a stack in the StateManager class. Each stat[详细]
2022-12-08 10:21 分类:问答