04 2011 档案
摘要:兩個可能性: new 失敗會 throw bad_alloc, 或傳回 0.這兩個可能性會導致兩個結果. 如果 new 拋 bad_alloc, 所有已經成功建構的物件 (如 base class, 其它成員物件) 都會解構. 尚未建構的物件不會建構. Caaa 物件也不會存在.如果 new 傳回 0, 你會有一個完整的物件, 但其內部的成員資料的完整性是個問題 ('total' 不是 0, 但 'ptr' 是 0). 你可以在 initialization list 裡抓成員所拋的 exceptions: Caaa::Caaa(int num, int *p)
阅读全文
摘要:代码贴上:#include <stdlib.h>#include <string.h>#include <time.h>#include <iostream>// using namespace std;int main(){ const char *c = "0123456789abcdefghijklmnopqrstuvwxyz"; srand(static_cast<unsigned int>(time(NULL))); std::cout << "The random char arr
阅读全文
摘要:1、 安装qt-sdk-win-opensource-2009.04.exe, 下载地址:http://qt.nokia.com/downloads/sdk-windows-cpp2、 安装。3、 设置环境变量。(假设安装到D盘) Path里面添加:d:\Qt\2009.04\qt\bin; 新加:QTDIR:d:\Qt\2009.04\qt4、安装Visual Studio 2008 ,必须打补丁SP15、打开 Visual Studio 2008 命令提示 进入Microsoft Visual Studio 9.0\Common7\Tools\目录下,执行vsvars32.bat,执行完,
阅读全文
摘要:摘自http://blog.sina.com.cn/s/blog_4b687eac0100f0oa.html21 22 ...20 789 1019 612 1118 543 1217 16 1514 13看清以上数字排列的规律,设 1 点的坐标是 (0,0),x 方向向右为正,y 方向向下为正。例如,7 的坐标为 (-1,-1),2的坐标为 (0,1),3 的坐标为 (1,1)。编程实现输入任意一点坐标 (x,y),输出所对应的数字。[Finland某著名通信设备公司 2005 年面试题]规律是什么?规律真的一看就能看出来,问题就在于如何利用它。先来个大点的:43 44 45 46 47 4
阅读全文