一、c++物件模型 在C++中,有兩種類資料成員:靜態和非靜態,以及三種類成員函數:靜態、非靜態和虛擬。比如下面的class Point的聲明: class Point { pulic: Point (float xval) virtual ~point(); float x() const; static int PointCount(); protected: virtual
26. Postpone variable definitions as long as possible.總結:儘可能延後變數定義式的出現。這樣做可增加程式的清晰度並改善程式效率。批註:純C語言此處有衝突,C語言要求變數定義出現在代碼快的開始部分。27. Minimize casting.1)const_cast 通常被用來將對象的常量性轉除(cast away the constness) 。它也是唯一有此能力的 C++-style
以前沒有怎麼注意C++繼承時候基類引用子類或基類指標指向子類。現在寫個小程式來測試下這種結果。// TestCPP.cpp : Defines the entry point for the console application.#include"stdafx.h"#include"iostream"using namespace std;class B{public: virtual void print() { cout<<"this is
SqlConnection con = new SqlConnection("Data Source=192.168.1.101;Initial Catalog=sun;Persist Security Info=True;User ID=sa;Password=123"); string time = DateTime.Now.ToString("yyyyMMddHHmmssfff"); string ab = time;
Item 33: 避免覆蓋(hiding)“通過繼承得到的名字”作者:Scott Meyers譯者:fatalerror99 (iTePub's Nirvana)發布:http://blog.csdn.net/fatalerror99/莎士比亞有一個關於名字的說法。"What's in a name?" 他問道,"A rose by any other name would smell as
Item 32: 確保 public inheritance 類比 "is-a"作者:Scott Meyers譯者:fatalerror99 (iTePub's Nirvana)發布:http://blog.csdn.net/fatalerror99/在 Some Must Watch While Some Must Sleep (W. H. Freeman and Company, 1974) 這本書中,William Dement