This is one of those mmm I wonder how you would do that questions. In C++, we can declare nameless classes like
In a named class, if I want Destroy to be called when the object is deleted, I put it in the destructor (~name). What is the syntax for the destructor in a nameless class? The only thing I can think of is a delete operator.
Code:
class
{
public:
void Create ()
{
...
}
void Destroy ()
{
...
}
} noname;
Code:
void operator ~() // doesn't get called
operator ~() // produces a syntax error
~() // produces a syntax error