Skip to content

Instantly share code, notes, and snippets.

@FelixZhang00
Created July 15, 2017 02:57
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 FelixZhang00/4bcfeec2ba3f8568a6da8e4151379800 to your computer and use it in GitHub Desktop.
Save FelixZhang00/4bcfeec2ba3f8568a6da8e4151379800 to your computer and use it in GitHub Desktop.
C++反汇编 析构函数的例子
#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