摘要:
#include <iostream>using namespace std;template <class T>struct plus{ T operator()(const T& x, const T& y) const { return x + y; }};template <class T>struct minus{ T operator()(const T& x, const T& y) const { return x - y; }};int main(){ plus<int> plusobj; min 阅读全文
摘要:
#include <iostream>#include <new>using namespace std;const int chunk = 16;class Foo{public: int val() { return __val; } Foo() { __val = 0; }private: int __val;};char *buf = new char[sizeof(Foo) * chunk];int main(int argc, char* argv[]){ Foo *pb = new (buf)Foo; if (pb->val() ... 阅读全文
摘要:
对于动态分配常量对象,我平时写代码从来没有用过。今天看C++书时注意到了。在VC6.0里测试了一下,结果VC6.0不支持。const int *pic = new const int(1000);注意:1、常量对象的动态分配和普通变量一样,可以动态释放。2、常量对象只能是基本数据类型,并在分配时,必须赋值。 阅读全文
摘要:
函数原型:BOOL WINAPI PostThreadMessage(_In_DWORD idThread,_In_UINT Msg,_In_WPARAM wParam,_In_LPARAM lParam);idThread - [in] Type: DWORD The identifier of the thread to which the message is to be posted.Msg - [in] Type: UINT The type of message to be posted.wParam - [in] Type: WPARAM Additional message-. 阅读全文
摘要:
The most beautiful formula in mathematics:e,j,PI,1,0仅出现一次。幂运算、乘、加、等于仅出现一次。 阅读全文