摘要: short usData = 0x1122; char *pucData = (char*)&usData; bool bBigEndian = (*pucData == 0x22); 阅读全文
posted @ 2008-07-01 16:38 能巴 阅读(434) 评论(0) 推荐(0)
摘要: 1. '\0'----字符串结束符。代表了0x00。 2. strcpy,strcat等函数,期待'\0'在源字符串中的出现。必须出现才能copy或连接成功。 3. 最好在每次使用前均使用memset(&buf,0,sizeof(buf))清空数据区,保证没错 阅读全文
posted @ 2008-07-01 15:44 能巴 阅读(239) 评论(0) 推荐(0)
摘要: char string[1]; // string[10] is the boundary example to tell the extra '0' in a c style string will also be copied when copying. char *str1="0123456789"; strcpy(string, str1); // 11 char will be cop... 阅读全文
posted @ 2008-07-01 15:22 能巴 阅读(842) 评论(0) 推荐(0)
摘要: Things to Remember:在一个独立的语句中将 new 出来的对象存入智能指针。如果疏忽了这一点,当异常发生时,可能引起微妙的资源泄漏。 下面这个函数调用还是可能泄漏资源。为什么? processWidget(std::tr1::shared_ptr(new Widget), priority()); ... 阅读全文
posted @ 2008-07-01 01:31 能巴 阅读(333) 评论(0) 推荐(0)
摘要: 1. STL的auto_ptr 缺点: 1)一个对象只能被一个auto_ptr所拥有,即所有权转移问题。 2)因此,它不能用在STL的container中,所以,非常不实用。 2. Boost的shared_ptr TR1中的std::tr1::shared_ptr就够了(#include ,use std :: tr1 :: shared_ptr using the VS2008 featur... 阅读全文
posted @ 2008-07-01 01:27 能巴 阅读(383) 评论(0) 推荐(0)
摘要: vs2008下安装boost 1.下载boost_1_34_1压缩文件,解压缩到d:\boost_1_34_1\目录下 2.编译bjam 从vs2008的工具菜单进入命令提示窗口"Visual Studio 2008 Command Prompt"(一定要从这进),cd到c:\boost_1_34_1\tools\jam\src下执行build.bat,会在c:\boos... 阅读全文
posted @ 2008-07-01 00:50 能巴 阅读(1067) 评论(0) 推荐(0)