《深度探索C++物件模型》讀書筆記(1)。 在C++中,有兩種class data members:static和nonstatic,以及三種class member functions:static、nonstatic和virtual.已知下面這個class Point聲明: class Point ...{public:Point(float xval);virtual ~Point();float x() const;static int PointCount();protected:
《深度探索C++物件模型》讀書筆記(3)。 在visual C++ 6.0中測試如下代碼: #include "iostream"using namespace std;class X {};class Y : public virtual X {};class Z : public virtual X {};class A : public Y,public Z {};int main(){ cout<<"sizeof(X): "<<sizeof(X)<
13. Use objects to manage resources.總結:第一,為了防止資源流失,請使用RAII對象,它們在建構函式中獲得資源並在西溝函數中釋放資源。第二,兩個常被使用的RAII class分別是tr1::shared_ptr和auto_ptr。前者通常是較佳選擇,因為其copy行為比較直觀。若選擇auto_ptr,複製動作會使它(被複製物)指向null。14.Think carefully about copying behavior in
49. Understand the behavior of the new-handler.總結:第一,set_new_handler允許客戶指定一個函數,在記憶體配置無法獲得滿足時被調用。第二,Nothrow new是一個頗為局限的工具,因為它只適用於記憶體配置;後繼的建構函式調用還是可能拋出異常。50. Understand when it makes sense to replace new and delete.替換編譯器提供的operator new或operator
WinForm下的ComboBox預設是以多行文本來設定顯示列表的, 這通常不符合大家日常的應用, 因為大家日常應用通常是鍵/值對的形式去綁定它的.那麼用索引值對的形式如何做?因為Combox的每一個項的值是一個object, 實際上就是一個鍵/值對.我用的是下面這個類的執行個體作為它的一個項:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->