Created
March 23, 2014 12:14
-
-
Save yuikns/9722299 to your computer and use it in GitHub Desktop.
a test of gc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
class MyClass | |
{ | |
public : | |
MyClass() | |
{ | |
printf("my class inited\n"); | |
} | |
~MyClass() | |
{ | |
printf("my class destoried\n"); | |
} | |
void call() | |
{ | |
printf("my class be called\n"); | |
} | |
}; | |
MyClass& bar() | |
{ | |
printf("bar start\n"); | |
MyClass * mc = new MyClass(); | |
printf("bar to return\n"); | |
return *mc; | |
} | |
void foo() | |
{ | |
printf("foo start\n"); | |
MyClass & mc = bar(); | |
mc.call(); | |
printf("foo to end\n"); | |
printf("my class call to delete\n"); | |
delete &mc; | |
printf("my class call to delete done\n"); | |
} | |
int main(int argc,char * argv[]) | |
{ | |
printf("main start\n"); | |
foo(); | |
printf("main to return\n"); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment