Posted on August 1st, 2010 at 20:08 by fr3@K
可能會出乎不少人的意料, 下面的 code snip 可能會拋出 exception.
-
Listing-1.
-
using namespace std;
-
T* new_t_nothrow()
-
{
-
return new (nothrow) T;
-
}
可能會出乎不少人的意料, 下面的 code snip 可能會拋出 exception.
你一定看過這樣的 code:
可讀性差的巢狀 if block, 只為了堅持由一處 return.
(more...)

想加入這篇 解读google C++ code style谈对C++的理解 的討論. 不幸由於不明原因, 一直被系統認為是廣告 (圖中紅字部份):
先留個底, 再看看該/能怎麼辦吧.
ps. cppblog 帳號申請中, 也許有帳號就沒這問題了吧? 不過, 看起來申請帳號要經過人工審核...
(more...)
這幾個月忙於工作, 這個部落格都快被我給荒廢掉了. 昨晚終於花了時間完成了一篇積了一兩個月, 說明 virtual function 在執行時期的 override 過程以及 virtual function 與 constructor/destructor 混搭結果 的文字.
今天我準備了個題目給花了時間看了它的朋友, 當作對小弟的說明能力來個測驗. 請問, 下面的 code snip 的輸出結果是什麼?
(more...)
不知道你有沒有過這樣的經驗 - 想要在父類的 constructor 裏面呼叫被子類 override (或是 implement) 的 (pure) virtual function?
(more...)
The issue with boost::decay documentation that I blogged about 10 days ago has been fixed in trunk.
前陣子看了 Hubert 的 一個 boost::exception 的例子, 猛然注意到自己不確定 boost::decay 的作用.
去看了它的 文件, 才發現文件不盡然正確... 已 submit 了一個 ticket 給 Boost, 希望早日修正.
Did you know, for x is an integer, that -~x yields x + 1 and ~-x yields x - 1?
elleryq 的 這篇 blog post 談到的 ctor (換成 dtor 也一樣) 呼叫 virtual function 狀況 (或說是 problem) 會是很好的 C++ programmer 面試題目. 可在口試時用以窺探 interviewee 對 C++ object model 的了解.
(more...)
Except where otherwise noted, COdE fr3@K by
fr3@K is licensed under a
Creative Commons Attribution-Share Alike 3.0 License.