Roger Luo

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

随笔分类 -  C/C++

摘要:Q:构造函数中涉及的大量内存分配以及复杂对象变量的初始化失败应该如何处理 应该放在initialize list里面 ClassA():objb(new ClassB) 这样如果失败了一些构造好的对象也会自动析构掉 有些方法: ClassA::ClassA(){ objb = new ClassB(); if(objb == NULL) { ... 阅读全文

posted @ 2013-03-18 13:38 Roger Luo 阅读(324) 评论(0) 推荐(0)

摘要:In Boost library, there are totally three libraries to support regex parser, regex, xpressive and .. the xpressive library is static compile, that means it will cause a lot of time to build your proj... 阅读全文

posted @ 2013-03-18 10:26 Roger Luo 阅读(303) 评论(0) 推荐(0)

摘要:bind function adapter (included <functional>) Introduce: bind(op, args, …) Binds args to op Simple Code auto pfn = std::bind(std::plus<int>(), std::placeholders::_1, 10);cout<<pfn(7); // 17 N... 阅读全文

posted @ 2013-03-16 17:30 Roger Luo 阅读(355) 评论(0) 推荐(0)

摘要:Go to Project Property Page/Cofniguration Properties General/Configuration Type, change as “Dynamic Library(.dll)” C/C++/Code Generation/Runtime Library, change as “/MDd” C/C++/Preprocessor/Preproc... 阅读全文

posted @ 2013-03-16 15:28 Roger Luo 阅读(332) 评论(0) 推荐(0)

摘要:C++ fstream fin;fin.open(filename, ios::in);if (!fin.good()){ cerr<<"Failed to open "<<filename<<endl; return -1;}fin.seekg(0, ios::end);size_t len = fin.tellg();char * raw = new char[len+1]... 阅读全文

posted @ 2013-03-16 12:55 Roger Luo 阅读(229) 评论(0) 推荐(0)

摘要:静态变量需要在.cpp初始化,否则报错连接错误, 对于原始数据, int, double, … simple.h class Simple{public: Simple(void); ~Simple(void); static int GetInt(void);private: static int _i;};simple.cpp int Simple::Ge... 阅读全文

posted @ 2013-03-15 17:15 Roger Luo 阅读(6026) 评论(0) 推荐(0)

摘要:内存映射文件 内存映射文件与虚拟内存有些类似,通过内存映射文件可以保留一个地址空间的区域,同时将物理存储器提交给此区域,只是内存文件映射的物理存储器来自一个已经存在于磁盘上的文件,而非系统的页文件,而且在对该文件进行操作之前必须首先对文件进行映射,就如同将整个文件从磁盘加载到内存。由此可以看出,使用内存映射文件处理存储于磁盘上的文件时,将不必再对文件执行I/O操作,这意味着在对文件进行处理时将不... 阅读全文

posted @ 2013-03-05 16:27 Roger Luo 阅读(2718) 评论(0) 推荐(0)

摘要:IO notification has 6 models 1. synchronous completion for “fast” I/O 2. polling 3. signaling the device kernel object directly 4. signaling an event object provided when I/O started 5. pos... 阅读全文

posted @ 2013-03-05 15:25 Roger Luo 阅读(319) 评论(0) 推荐(0)

摘要:Create file HANDLE hFile = ::CreateFile(lpcszFileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAY... 阅读全文

posted @ 2013-03-05 11:27 Roger Luo 阅读(289) 评论(0) 推荐(0)

摘要:Switching Windows Project and Console Project If you build up a win32 console project and want to convert to windwos application. You should change the subsystem property on link/subsystem from /co... 阅读全文

posted @ 2013-02-28 15:34 Roger Luo 阅读(616) 评论(0) 推荐(0)

摘要:Structure Introduction typedef struct hostent { char FAR *h_name; char FAR FAR **h_aliases; short h_addrtype; short h_length; char FAR FAR **h_addr_list;} HOSTENT, *P... 阅读全文

posted @ 2013-02-20 09:57 Roger Luo 阅读(331) 评论(0) 推荐(0)

摘要:void cast of argc and argv stop the compiler from complaining about unused variables int main(int argc, char **argv){ (void)argc; /* we don't use any arguments in this example */ (void)a... 阅读全文

posted @ 2013-02-08 03:24 Roger Luo 阅读(286) 评论(0) 推荐(0)

摘要:typedef struct _OVERLAPPED { ULONG_PTR Internal; ULONG_PTR InternalHigh; union { struct { DWORD Offset; DWORD OffsetHigh; }; PVOID Pointer; }; HANDLE hEvent;} OVERLAP... 阅读全文

posted @ 2013-02-08 01:50 Roger Luo 阅读(161) 评论(0) 推荐(0)

摘要:Exception Handling Stack around the variable was corrupted 内存越界将会导致这个异常出现,例如如下代码: void Reset(void * pv){ if (pv) { double * pd = reinterpret_cast<double *>(pv); *pd = 0.0; ... 阅读全文

posted @ 2013-02-07 14:19 Roger Luo 阅读(209) 评论(0) 推荐(0)

摘要:Background UTC: Coordinated Universal Time. GMT: Greenwich Mean Time. FILETIME: LOCALTIME: SYSTEMTIME: STRUCTURE/DEFINITION For windows SYSTEMTIME structure. The time is either in coordinated ... 阅读全文

posted @ 2013-02-05 14:08 Roger Luo 阅读(507) 评论(0) 推荐(0)

摘要:Preparation Using visual studio to create dll binary as your project in order to reuse code conveniently. 1. Install visual studio which includes visual c++ 2. Create a new project (File/Create/Pro... 阅读全文

posted @ 2013-01-31 11:26 Roger Luo 阅读(221) 评论(0) 推荐(0)

摘要:Compiling On windows platform, goto the unpack folder, such as d:/libcurl/curl, find the winbuild diretory. Open the vs command line window and use “nmake makefile.vc” to compile the code, here is th... 阅读全文

posted @ 2013-01-30 23:35 Roger Luo 阅读(1207) 评论(0) 推荐(0)

摘要:Windows Socket 2 A socket handle can optionally be a file handle in Windows Sockets 2. A socket handle from a Winsock provider can be used with other non-Winsock functions such as ReadFile, Wri... 阅读全文

posted @ 2013-01-12 13:45 Roger Luo 阅读(1144) 评论(0) 推荐(0)

摘要:methods1. GetVersionDWORD WINAPI GetVersion(void);The following illustration shows the format of the bits in system version.+-------------+----------+-------------------------+| Reserved | Build Id | Minor | Major |+-------------+----------+-------------------------+31 30 29 16 15 8 7 ... 阅读全文

posted @ 2013-01-05 18:31 Roger Luo 阅读(347) 评论(0) 推荐(0)

摘要:NLS(National Language Support)Background(背景)Each language has a language name and a language identifierthat indicate the particular code page (ANSI, DOS, Macintosh) used to represent the geographical location for the language on the operating system.Data Type(数据类型)typedef WORD LANGID; typedef DWORD 阅读全文

posted @ 2013-01-05 17:07 Roger Luo 阅读(285) 评论(0) 推荐(0)