카테고리 없음
c ++ 에서 static 변수 접근
벤치마킹
2012. 6. 29. 09:51
friend 함수에서
static 멤버 변수를 접근할때
class A{
static int no;
public:
A();
friend void func(void);
};
cpp 파일에서
int A::no ;// 선언을 해주고
A::A(void){
A::no = 1; //초기화 //
}
//friend 에서 A::no 이렇게 사용이 가능//
// A aa; A bb; 하지만 aa.no 와 b.no 는 같은 값을 가르키게 된다 . //
void func(void){
A::no = 3;
}