05 2011 档案

C++之乱七八糟<真正的随笔>
摘要:1、new和deleteint* pi = new int(0); //把值初始化为0A* pA = new A(); //对于自定义类型,创建对象分两步,第一步分配内存,第二步调用构造函数 A()是构造函数。pA->function();delete pA; //对于自定义类型,第一步调用析构函数,第二步释放内存。int *pi = new int[10];delete []pi; //申请10个元素的一维数组int **pi = new int[5][6];delete [][]pi;//申请一个二维数组。const int *pci = new const int(1024);动态 阅读全文

posted @ 2011-05-24 14:06 陈朋 阅读(414) 评论(0) 推荐(0)

运算符重载
摘要:1、重载单目运算符。class CPoint{ int x,y; public: CPoint(int vx,int vy) {x=vx;y=vy;} CPoint(){x=0;y=0;} void Print(); CPoint operator++(); //前置++运算符的声明 CPoint operator--(); //前置--运算符的声明};void CPoint::Print(){cout<<"("<<x<<","<<y<<")\t";}CPoint CPoin 阅读全文

posted @ 2011-05-24 12:53 陈朋 阅读(1072) 评论(0) 推荐(0)

宽字节与多字节转换
摘要:int iTextLen; iTextLen = WideCharToMultiByte ( CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL); pElementText = new char[iTextLen + 1]; memset( ( void* )pElementText, 0, sizeof( char ) * ( iTextLen + 1 ) ); ::WideCharToMultiByte( CP_UTF8,0,str,-1,pElementText,iTextLen,NULL,NULL ); 阅读全文

posted @ 2011-05-23 21:16 陈朋 阅读(1791) 评论(0) 推荐(0)

使用快捷键弹出新对话框
摘要:第一、快捷键: 1、响应按键消息:使用PreTranslateMessage,mfc处理消息之前,通常在这里做处理。该函数使用时要从CWin的虚函数PreTranslateMessage中重载。 2、按键,好吧,就在下面;后面括号的是对应的ASCII码ESC键 VK_ESCAPE (27)回车键: VK_RETURN (13)TAB键: VK_TAB (9)Caps Lock键: VK_CAPITAL (20)Shift键: VK_SHIFT ($10)Ctrl键: VK_CONTROL (17)Alt键: VK_MENU (18)空格键: VK_SPACE ($20/32)退格键: VK_B 阅读全文

posted @ 2011-05-12 14:54 陈朋 阅读(2543) 评论(0) 推荐(0)