随笔分类 -  C/C++

摘要:在代码中直接调用DebugBreak()函数,可以使程序中断运行,和在IDE中设置断点中断运行的道理是一样的。用这种方式,一些情况下比打断点更方便调试,如下,在test()函数返回0时激活断点#include "debugapi.h"int test(int x){ if (x > 0) return 1; return 0;}int _tmain(int argc, _TCHAR* argv[]){ if (test(-1) == 0) { DebugBreak(); } return 0;}有时编译时编译器会报一个"No Target Architect 阅读全文
posted @ 2013-09-20 23:52 linear 阅读(931) 评论(0) 推荐(0)
摘要:C++里,如果程序员没有显式的定义默认构造函数(default constructor),编译器会在需要的时候生成一个,也就是隐式地声明出来。隐式声明的默认构造函数有两种,一种是trivial(无用的) constructor,什么都不做;另一种是nontrival constructor,编译器合成的是后者。在四种情况下,编译器需要合成nontrival constructor:1. 带有"Default Constructor"的成员类对象class A {public: A(), ... };class B {public: A a;};int f(){ B b; / 阅读全文
posted @ 2013-01-06 20:43 linear 阅读(1188) 评论(0) 推荐(0)