const, const 멤버 함수와 비 const 멤버함수


const, const 멤버 함수와 비 const 멤버함수

Colored By Color Scripter 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 #include <iostream> class Point{ int x; int y; public: Point(int _x = 0, int _y = 0):x(_x),y(_y){} int GetX() const{return x;} int GetY() const{return y;} void SetX(int _x){x=_x;} void SetY(int _y){y=_y;} void Print() const { cout << x << ',' << y << endl;} }; int main(){ const Point p1(0,0); Point p2(2,3); p1.Print(); p2.Print(); cout << "p1: " << p1.GetX() << ',' <<p1.GetY() << endl; c...



원문링크 : const, const 멤버 함수와 비 const 멤버함수