摘要: Declaring a member function with the const keyword specifies that the function is a "read-only" function that does not modify the object for which it is called.To declare a constant member function, place the const keyword after the closing parenthesis of the argument list. The const keywo 阅读全文
posted @ 2012-11-13 21:16 avexer 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 1.重载一元操作符To declare a unary operator function as a nonstatic member, you must declare it in the form:ret-typeoperatorop()where ret-type is the return type and op is one of the operators listed in the preceding table.To declare a unary operator function as a global function, you must declare it in th 阅读全文
posted @ 2012-11-05 11:55 avexer 阅读(315) 评论(0) 推荐(0) 编辑
摘要: Comparing Two High-Performance I/O Design Patterns by Alexander Libman with Vladimir Gilbourd November 25, 2005 Summary This article investigates and compares different design patterns of high per... 阅读全文
posted @ 2012-11-02 14:58 avexer 阅读(146) 评论(0) 推荐(0) 编辑
摘要: class base{public: void sayhello(int n) { std::cout<<n<<std::endl; }};class sub : public base{public: void sayhello(char *msg) { std::cout<<msg<<std::endl; } void... 阅读全文
posted @ 2012-10-16 16:42 avexer 阅读(95) 评论(0) 推荐(0) 编辑
摘要: 实际上,new在C++中有3种用法,不过我们一般只使用其中的一种。new operatoroperator newplacement new第1种:Object *obj = new Object();这是我们这辈子主要接触的new。其实这个new中包含了下面的两个new的作用:分配内存,构造对象。第2种:分配内存,这个new你可以重载的。void* operator new(size_t size){ return malloc(size);}第3种:指定内存处构造对象void *lpstart = malloc(sizeof(Object));new(lpstart) Object();补 阅读全文
posted @ 2012-09-27 13:07 avexer 阅读(127) 评论(0) 推荐(0) 编辑
摘要: WCHAR* SysAllocString(WCHAR *str) { size_t sz = 4 + wcslen(str)*sizeof(WCHAR); WCHAR *lpstart = malloc(); *(int*)lpstart = sz; wcscpy(lpstart+2,str); return lpstart + 2; } void S... 阅读全文
posted @ 2012-09-25 16:27 avexer 阅读(335) 评论(0) 推荐(0) 编辑