C++ static member function
![[C++] static member function](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FdALAKf%2FbtqzOWpyDb5%2FUOX2ZgQ2QPc3kIRlVpeJH0%2Fimg.png)
[C++] static member function
1. 정적 멤버 함수 (static member function) class Car { int speed; static int cnt; public: Car() { ++cnt; } ~Car() { --cnt; } int getCount() { return cnt; } }; int Car::cnt = 0; int main() { Car c1, c2, c3; c1.getCount(); } static member data는 객체를 생성하지 않아도 메모리에 올라간다. 위의 코드에서는 getCount() 함수를 통해 객체의 개수를 파악하고 있다. 그런데, 객체를 생성하지 않은 상태에서 개수를 파악하고 싶을 때 getCount()를 어떻게 호출할까? static int getCount() { return cnt;..