Skip to content

Instantly share code, notes, and snippets.

@norbekaiser
Created September 19, 2016 05:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save norbekaiser/4e3f97f20cf065c13328bd4e24b1e35f to your computer and use it in GitHub Desktop.
Save norbekaiser/4e3f97f20cf065c13328bd4e24b1e35f to your computer and use it in GitHub Desktop.
delete this , "meh"
Huhu gone
h1 ex
h2 ex
#include <iostream>
class hue{
public:
hue(){
};
~hue() { std::cout << "Hue gone"<<std::endl; }
};
class huhu{
public:
huhu(){
delete this;
return;
};
~huhu() { std::cout << "Huhu gone"<<std::endl; }
};
int main(){
using namespace std;
hue* h1 = new hue();
huhu* h2 = new huhu();
if(h1){ cout<< "h1 ex"<< endl;; }
else { cerr<<"h1 nex"<<endl; }
if(h2){ cout<< "h2 ex"<< endl;; }
else { cerr<<"h2 nex"<<endl; }
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment