2011-03-14 100 views

回答

4

它的構造函數的初始化列表中。如果使用編譯器生成的構造函數,則原理相同,只是隱式生成。

5

在構造函數。構造函數用於初始化類的非靜態成員。


class foo 
{ 
    static int num; // static variable don't belong to any particular instance of a class. 
    foo(){} 
}; 

所以,像這樣做相應的源文件中 -

int foo::num = 10 ; 
+0

謝謝你,怎麼樣靜態成員? – user658213 2011-03-14 05:30:36

+0

@ user658213 - 查看我的編輯。 – Mahesh 2011-03-14 05:34:37

相關問題