2009年9月23日

摘要: 假设你有一个对话框,上面有一个EditBox,接着你用类向导,为这个EditBox建立了一个double型变量m_dv1。 紧接着,你发现MFC提供的从string到double的转换无法满足你的需要。你的输入是一个带单位的长度,比如: 100mm 而MFC完全不懂“mm“是什么意思。不过好在,你已经有这样两个函数: 1: CString lengthToString(double); 2:... 阅读全文
posted @ 2009-09-23 16:13 Tactoth 阅读(1031) 评论(1) 推荐(0) 编辑

2009年9月22日

摘要: 刚刚看到一则有趣的消息:近日,Google Jobs在MIT校园内到处张贴着一份密码,企图在MIT校园里的一群变态中找出几个最变态的破密大牛。密码上面附文说,如果你能破解这份密码,你在Google会很有前途。据说,这份密码包含了一个Google Jobs的电话号码,解开密码的人可以通过此电话留下自己的个人信息。目前,还没有人破解出这段密码来。   赶紧碰碰运气吧! 阅读全文
posted @ 2009-09-22 18:36 Tactoth 阅读(225) 评论(0) 推荐(0) 编辑

2009年9月18日

摘要: 不知道大家有没有遇到这样的情况,有时候我们需要在代码中使用一个常数,比如-标签的颜色。但关于这个常数取什么值,我们却想逐个看看,比如: 1: const COLORREF color2=RGB(75,150,25); // what color do I like? 2: CBrush brush2(color2); 3: dc.SelectObject(&brush2); 4: dc.C... 阅读全文
posted @ 2009-09-18 14:31 Tactoth 阅读(201) 评论(0) 推荐(0) 编辑

2009年9月17日

摘要: 可以说使用C++的过程是一个充满了惊喜的过程,因为常常的,会听说新鲜实用的语言特性,比如,函数重载: 1: void func(int i); 2: void func(double d); 3: void func(const char* s);在调用func的时候,根据所传参数的类型,编译器会自动选择合适的函数。但是,在这个例子中,C++却没有给我惊喜: 1: void func(const ... 阅读全文
posted @ 2009-09-17 19:21 Tactoth 阅读(285) 评论(4) 推荐(0) 编辑

2009年9月14日

摘要: 其实发现这个特性很长时间了。在Opera里用Google随便搜索什么关键字,比如“码农看世界”: http://www.google.com/search?hl=en&source=hp&q=%E7%A0%81%E5%86%9C%E7%9C%8B%E4%B8%96%E7%95%8C&btnG=Google+Search&aq=f&oq=&aqi= ... 阅读全文
posted @ 2009-09-14 12:57 Tactoth 阅读(356) 评论(0) 推荐(1) 编辑

2009年9月12日

摘要: Recently I worked on a cpp code beatifier, it reads in a cpp file, analysis the content and beautify the format, then write the file back. In my code there's a function like this: void beautify_a_fil... 阅读全文
posted @ 2009-09-12 20:55 Tactoth 阅读(195) 评论(0) 推荐(0) 编辑
摘要: I've heard many people say auto_ptr is very error-proven. The main issue is the assign operator, for underlying it's a swap. I believe this is a design mistake too: auo_ptr should have disabled copy c... 阅读全文
posted @ 2009-09-12 20:53 Tactoth 阅读(120) 评论(0) 推荐(0) 编辑
摘要: Look at this code: string* ps=new string("hello, world"); As is known this code first allocate a memory block of sizeof(string), then call string’s constructor to "make the memory be a string object... 阅读全文
posted @ 2009-09-12 20:51 Tactoth 阅读(138) 评论(0) 推荐(0) 编辑
摘要: No loop, no EOF test. Just one line: ifstream ifs("test.txt");string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>()); ========================================... 阅读全文
posted @ 2009-09-12 20:48 Tactoth 阅读(380) 评论(0) 推荐(0) 编辑
摘要: 偶尔发现QQ上有两位好友的签名都是: “临渊羡渔,不如退而结网” 为了保持本人特立独行的传统美德,特意将QQ签名改为: “退而结网,不如临渊羡鱼” 注意由于本人的诸多良好习惯之一,已经成功的将“渔”错打为“鱼”。但我的本意还是“渔”。Tactoth这样讲,自然也不可避免的带了些超级深邃莫测无敌的寓意在其中:你怎么知道人家都是用网的呢?说不定人家用机关枪扫鱼呢!通过这句话,Tactoth意在... 阅读全文
posted @ 2009-09-12 10:15 Tactoth 阅读(293) 评论(0) 推荐(1) 编辑

导航