Roger Luo

超越梦想一起飞
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

11 2012 档案

摘要:多线程编程使用createthread需要提供LPTHREAD_START_ROUTINE线程函数,线程函数的签名为 void (*) (void * lpParam)对于类静态函数或者全局函数,需要在LPTHREAD_START_ROUTINE强制定义ThreadProc类静态函数:需要(LPTHREAD_START_ROUTINE)Class::StaticFunction全局函数:需要(LPTHREAD_START_ROUTINE)GlobalFunctioncreatethread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadProc, pParam, 阅读全文

posted @ 2012-11-23 17:42 Roger Luo 阅读(810) 评论(0) 推荐(0)

摘要:Copy and Swap idiom使用到著名的Big three中兩個特殊的成員函數(拷貝構造函數copy construction與賦值構造函數assignment constrcution). 作用在于在深拷贝的过程中保证强异常的作用,具体代码如下class Person { public: Person(int id, const char * pszName):_id(id), _pszName(new char[strlen(pszName) + 1]){strcpy(_pszName, pszName);} Person():_id(0) { _pszName = n... 阅读全文

posted @ 2012-11-20 19:58 Roger Luo 阅读(856) 评论(0) 推荐(0)

摘要:啊 阅读全文

posted @ 2012-11-20 15:58 Roger Luo 阅读(178) 评论(0) 推荐(0)

摘要:饭是一口一口吃的...预编译 PrecompilerCompiling C++ code is a long, slow process, especially compiling window API or other API library(boost).The Microsoft compiler can ameliorate this problem with a simple trick calledprecompiled headers. The trick is pretty slick: although every CPP file can potentially and l 阅读全文

posted @ 2012-11-17 14:07 Roger Luo 阅读(203) 评论(0) 推荐(0)

摘要:Mac XCode program1. Add additional header/librariesFor XCode project, add the "Header Search Paths" or "Library Search Paths" under "Search Paths" in xcodeproj.2. Add additional link flagsFor XCode project, for example, add "-lboost_system-xgcc42-1_51" and &qu 阅读全文

posted @ 2012-11-15 21:28 Roger Luo 阅读(250) 评论(0) 推荐(0)

摘要:Install BOOST 1. Build from source code Download the new release package from boost official website For windows, download zip or 7z format and unpack it using 7zip or winrar For linux/mac os, dow... 阅读全文

posted @ 2012-11-15 08:55 Roger Luo 阅读(390) 评论(0) 推荐(0)

摘要:convert char * to wchar_t *using mbstowcs function char psz[] = {"helloworld\0"}; wchar_t pwsz [10] = {0}; int len = strlen(psz); int ret = mbstowcs(pwsz, psz, min(len, 10)); cout<<ret<<endl; wcout<<pwsz<<endl;Note: if the dest has less space than src, that will cau 阅读全文

posted @ 2012-11-08 16:05 Roger Luo 阅读(188) 评论(0) 推荐(0)

摘要:Debug logSometimes we need to print some logs to show the application is running well during debug. But for release version, we choose to ignore these logs.So we can use macros to finish these function, in that way, no need to change the code.#ifdef _DEBUG #define DPRINT(...) printf(__VA_ARGS__) #el 阅读全文

posted @ 2012-11-08 12:56 Roger Luo 阅读(204) 评论(0) 推荐(0)

摘要:traverse elements in contianer associated container: set Compare between sets if you want to find the different elements in one set to another set, you could use the std::set_difference met... 阅读全文

posted @ 2012-11-07 15:56 Roger Luo 阅读(279) 评论(0) 推荐(0)