答案是什么
2016-01-18 16:35
148 查看
#include <new> class CDirObj { public: void* operator new(size_t sz) { printf("operator new\n"); return ::operator new(sz); } void operator delete(void* p) { printf("operator delete\n"); ::operator delete(p); } CDirObj::CDirObj() { printf("构造 %d\n", this); m_pStr = new char[1024]; } CDirObj::CDirObj(const char* pStr) { printf("其他构造 %d\n", this); CDirObj(); } CDirObj::~CDirObj() { printf("析构 %d\n", this); delete m_pStr; } const char* m_pStr; }; #include <iostream> class CTest { public: CTest() { m_a = 1; printf("构造CTest %d\n", this); } CTest(int b) { m_b = b; CTest(); printf("其他构造CTest %d\n", this); } ~CTest() { printf("析构CTest %d\n", this); } void show() { std::cout << m_a << std::endl; std::cout << m_b << std::endl; } int m_a; int m_b; }; int _tmain(int argc, _TCHAR* argv[]) { CTest myTest(2); myTest.show(); CDirObj* pObje = new CDirObj("HELLO"); delete pObje; return 0; }
相关文章推荐
- 关于C++ const 的全面总结
- Scala编程之螺旋
- Log4j.properties配置
- FT系列touch---------suspend和resume的实现
- 逗号表达式
- php中__autoload()方法详解
- IOS开发教程--关于点击IPHONE手机标题栏无法滚动到最顶端问题
- 深入学习jQuery Validate表单验证(二)
- PHP 5.0 的 新特性
- php中的short_open_tag的作用
- ORA-28001: the password has expired
- android中常见的内存泄露场景
- 备忘录模式
- excel 中任意几个数相加后等于一个数
- 网站发布后在IIS上定时执行任务
- C++中使用TinyXML2
- Android Studio 解决方法数超过65536,导致dex无法生成的问题
- Summary of Amazon Marketplace Web Service
- GlusterFS无法启动原因及处理方案
- 关于的垂直居中的问题