#include <iostream>
using namespace std;
#define HERAKLIT_TASK 1
class HeapOnly {
public :
HeapOnly( ) { }
void destroy( ) const { delete this ; }
protected :
~HeapOnly( ) { }
} ;
//HeapOnly h1; // Destructor is protected so h1 can't be created globally
//HeapOnly func() // Compiler error because destructor of temporary is protected
//{
// HeapOnly *hoptr = new HeapOnly; // This is ok. No destructor is invoked automatically for heap-based objects
// return *hoptr;
//}
int main( void ) {
#if HERAKLIT_TASK
HeapOnly h2; // Destructor is protected so h2 can't be created on stack
#else
HeapOnly * hptr = new HeapOnly( ) ;
delete hptr;
#endif
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwogCiNkZWZpbmUgSEVSQUtMSVRfVEFTSyAxCiAKY2xhc3MgSGVhcE9ubHkgewogIHB1YmxpYzoKICAgIEhlYXBPbmx5KCkge30gCiAgICB2b2lkIGRlc3Ryb3koKSBjb25zdCB7IGRlbGV0ZSB0aGlzOyB9CiAgcHJvdGVjdGVkOgogICAgfkhlYXBPbmx5KCkge30KfTsKLy9IZWFwT25seSBoMTsgICAgIC8vIERlc3RydWN0b3IgaXMgcHJvdGVjdGVkIHNvIGgxIGNhbid0IGJlIGNyZWF0ZWQgZ2xvYmFsbHkKLy9IZWFwT25seSBmdW5jKCkgIC8vIENvbXBpbGVyIGVycm9yIGJlY2F1c2UgZGVzdHJ1Y3RvciBvZiB0ZW1wb3JhcnkgaXMgcHJvdGVjdGVkCi8vewogLy8gSGVhcE9ubHkgKmhvcHRyID0gbmV3IEhlYXBPbmx5OyAvLyBUaGlzIGlzIG9rLiBObyBkZXN0cnVjdG9yIGlzIGludm9rZWQgYXV0b21hdGljYWxseSBmb3IgaGVhcC1iYXNlZCBvYmplY3RzCiAvLyByZXR1cm4gICAqaG9wdHI7Ci8vfQppbnQgbWFpbih2b2lkKSB7CiNpZiBIRVJBS0xJVF9UQVNLCiAgSGVhcE9ubHkgaDI7IC8vIERlc3RydWN0b3IgaXMgcHJvdGVjdGVkIHNvIGgyIGNhbid0IGJlIGNyZWF0ZWQgb24gc3RhY2sKI2Vsc2UKICBIZWFwT25seSAqIGhwdHIgPSBuZXcgSGVhcE9ubHkoKTsKICBkZWxldGUgaHB0cjsKI2VuZGlmCiAgcmV0dXJuIDA7Cn0=