随笔分类 - C++
摘要:(一)inline函数(摘自C++ Primer的第三版)在函数声明或定义中函数返回类型前加上关键字inline即把min()指定为内联。 inline int min(int first, int secend) {/****/}; inline函数对编译器而言必须是可见的,以便它能够在调用点内展...
阅读全文
摘要:被人问到这个问题,各种解决。google一下,MFC中有一个OFFSET宏,就有这个功能。写一下:#define offsetof(structure, member) ((int)(&((structure *)0)->member))eg:#include using namespace std...
阅读全文
摘要:#include #include using namespace std;class Phone{public: Phone(string name); virtual ~Phone(){coutprint(); delete pPhone; pPhone = new Iphone("HTC",...
阅读全文
摘要:自己习惯C++1、C++为一个语言联邦STL,Template,智能指针,C++112、尽量以const,enum,inline替换#define1)预处理在符号表中不存在,出现bug不好定位;目标码中也不会有多份Piaeg:#define Pia 3.14 (instead of--->) con...
阅读全文
浙公网安备 33010602011771号