1> A static data member can be of the same class type as that of which it is a member. a nonstatic data member is restricted to being decleared as a pointer or a reference to an object of its class.
2> static成员变量能够作为当前class的成员函数的默认参数,但是non-static则不可以
3>对于static成员函数的声明和定义,在class 中声明时要标注static关键字,而在class外部定义时,一定不要写static.
4>static 函数中要注意什么?
[list=1]
[*]·不能有this 指针
[*]·不能引用class中的非static成员(变量、成员)
[*]·static的成员函数不能再声明成volatile或const
[/list]
class Bar{
private:
static Bar mem1; //ok
Bar *mem2; //ok
Bar mem3; //error
}
2> static成员变量能够作为当前class的成员函数的默认参数,但是non-static则不可以
3>对于static成员函数的声明和定义,在class 中声明时要标注static关键字,而在class外部定义时,一定不要写static.
4>static 函数中要注意什么?
[list=1]
[*]·不能有this 指针
[*]·不能引用class中的非static成员(变量、成员)
[*]·static的成员函数不能再声明成volatile或const
[/list]