摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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... 阅读全文
摘要:
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... 阅读全文
摘要:
实际上,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();补 阅读全文
摘要:
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... 阅读全文