Created
July 15, 2017 02:57
-
-
Save FelixZhang00/4bcfeec2ba3f8568a6da8e4151379800 to your computer and use it in GitHub Desktop.
C++反汇编 析构函数的例子
This file contains 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 <stdio.h> | |
class BaseClass { | |
public: | |
BaseClass(){x=1;y=2;}; | |
virtual ~BaseClass(){printf("~BaseClass()\n");}; | |
virtual void vfunc1() = 0; | |
private: | |
int x;//4字节 | |
int y; | |
}; | |
class SubClass : public BaseClass { | |
public: | |
SubClass(){z=3;}; | |
virtual ~SubClass(){printf("~SubClass()\n");}; | |
virtual void vfunc1(){}; | |
private: | |
int z; | |
}; | |
int main() { | |
BaseClass *a_ptr = new SubClass(); | |
//触发析构 | |
delete a_ptr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment