글
Static Member
Programming/C++ Language
2009. 5. 31. 22:59
Static Data Member has Class Scope. Static Member could be defined as Public, Protected, Private. It must to be defined once in File Scope, such as "CGameUnit* CGameUnit::aUserUnit[2] = {NULL, NULL};". Because If you don't, Compiler makes "error LNK2001", "fatal error LNK1120: 1개의 확인할 수 없는 외부 참조입니다.", "외부 기호를 확인할 수 없습니다.".
The case of Public static, U can use this with Binary Scope resolution operator( :: ) and a name of Class, such as "Martian::martiancount".
The case of Private or Protected static, Public static Member function must be exist. This Public Static Function must be called with a name of Class and "::".
When it's inherited, If it's Public or Protected, U could use it w/out Public Static Function in inherited Class. Buf if it's Private, U must use it via Public Static Function in inherited Class.
The case of Public static, U can use this with Binary Scope resolution operator( :: ) and a name of Class, such as "Martian::martiancount".
The case of Private or Protected static, Public static Member function must be exist. This Public Static Function must be called with a name of Class and "::".
When it's inherited, If it's Public or Protected, U could use it w/out Public Static Function in inherited Class. Buf if it's Private, U must use it via Public Static Function in inherited Class.
'Programming > C++ Language' 카테고리의 다른 글
namespace (0) | 2010.03.19 |
---|---|
연산자 오버로딩 (0) | 2009.09.30 |
순수 가상 함수 (0) | 2009.09.26 |
가상 함수의 활용 (0) | 2009.09.25 |
가상 함수에 대한 이해 (0) | 2009.09.25 |