PL/C++

[C++] static 멤버 사용하기

SweetDev 2021. 12. 15. 10:30

'클래스명::static멤버' 로 접근해야 한다. 

Person::sharedMoney = 200;
Person::addShared(200);

 

non-static이면 에러를 뿜뿜할 것이다..

 

non-static멤버는 static에 접근할 수 있지만 static멤버는 non-static에 접근할 수 없다.