(1)假設我要運行windows下的a程式 [root@localhost ~]# wine a err:process:init_windows_dirs directory L"C://windows" could not be created, error 2 err:process:init_windows_dirs directory L"C://windows//system32" could not be
繼續整理第四章的內容,註:以下部分圖片來自於原文 1. 單繼承情況下的虛函數調用: 對於多態虛函數的調用(通過基類指標或者引用),例如ptr->z();,需要知道兩個資訊: a. ptr所指對象的真實類型,這可以使我們選擇正確的z()實體; b. z()實體位置,以便可以調用它。 結合以上的所需資訊,需要為每一個多態的類對象身上增加兩個成員: a.
繼續整理第五章剩下的內容,關於解構函式語義的。 1. 如果類沒有定義解構函式,那麼只有類中含有成員對象(或者本類的基類)擁有解構函式的情況下,編譯器才會合成一個出來,否則解構函式被視為不要,也就不需要合成。例如,如下類,雖然Point類擁有虛函數: class Point {piblic: Point(float x = 0.0, float y = 0.0); Point (const Point&); virtual float
當父類與子類有同名且變數時: class Base { public: int i; Base() { printf("Base()\n"); i = 99; amethod(); } void amethod() { printf("Base.amethod()\n"); } }; class Derived : public Base { public: int i; Derived() {
Continued with last post.. now I'm using C++ meta-programming to solve this problem - all computation moved to compile time. But there are limitations for G++ to compile template like recursion depth limitation and greediness... Please find
繼續整理第六章剩下的內容,關於臨時對象的幾條準則。 1. 在某些情況下,編譯器可以產生必要的,或者可以帶來方便的臨時對象,具體行為由編譯器來定義。例如,對於如下操作: T a, b;T c = a + b;//T operator+ (const T&, const T&)a. 編譯器會產生一個臨時對象,放置a+b的結果,然後使用T的拷貝建構函式,把臨時對象當作c的初始值。 b.
“new”是C++的一個關鍵字,同時也是操作符。關於new的話題非常多,因為它確實比較複雜,也非常神秘,下面我將把我瞭解到的與new有關的內容做一個總結。 new的過程 當我們使用關鍵字new在堆上動態建立一個對象時,它實際上做了三件事:獲得一塊記憶體空間、調用建構函式、返回正確的指標。當然,如果我們建立的是簡單類型的變數,那麼第二步會被省略。假如我們定義了如下一個類A: class A { int