Skip to content

Instantly share code, notes, and snippets.

@domiyanyue
Created August 10, 2020 01:40
Show Gist options
  • Save domiyanyue/cc1899da38bd076e6691d051102ce47d to your computer and use it in GitHub Desktop.
Save domiyanyue/cc1899da38bd076e6691d051102ce47d to your computer and use it in GitHub Desktop.
RAII example 2
int demo2(){
A *a = new A;
int ra = a -> func();
if(ra == 2) {
B *b = new B;
int rb = b->func();
delete a;
delete b;
return rb;
} else if(ra == 1) {
C *c = new C;
int rc = c->func();
delete a;
delete c;
return rc;
}
delete a;
return ra;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment