Technote/Data Structure C++ [C++] public & private Pooh0216 2009. 9. 18. 00:48 #include using std::cout; using std::endl; const int OPEN=1; const int CLOSE=2; class Door{ private: int state; public: void Open(){ state=OPEN; } void Close(){ state=CLOSE; } void ShowState(){ cout<<"현재 문의 상태: "; cout<<((state==OPEN)? "OPEN" : "CLOSE")<<endl; } }; int main() { Door d; //d.state=OPEN; d.Open(); d.ShowState(); return 0; } #include using std::cout; using std::endl; const int OPEN=1; const int CLOSE=2; class Door{ private: int state; public: void Open(); void Close(); void ShowState(); }; void Door::Open(){ state=OPEN; } void Door::Close(){ state=CLOSE; } void Door::ShowState(){ cout<<"현재 문의 상태: "; cout<<((state==OPEN)? "OPEN" : "CLOSE")< 저작자표시 (새창열림)