close

為了讓class所有物件都可取用的global物件

但又不希望非class成員可以access

 

不帶this

Static 變數只會被初始化1,類似global變數

Const static成員變數可在class內直接初始化

(VC++6.0 如果直接在class內初始化static const成員compiler不會過)

Ex:

class test

{

 

 

public:

           test();

           number print();

           static const int x;

 

private:

           int a;

           int b;

           int c;

 

};

 

const int test::x = 3;

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 flyinsky76 的頭像
    flyinsky76

    Deja Vu

    flyinsky76 發表在 痞客邦 留言(0) 人氣()