mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 20:54:41 +03:00
C.131: getters should be const member functions
This commit is contained in:
@@ -6393,9 +6393,9 @@ A trivial getter or setter adds no semantic value; the data item could just as w
|
|||||||
int y;
|
int y;
|
||||||
public:
|
public:
|
||||||
Point(int xx, int yy) : x{xx}, y{yy} { }
|
Point(int xx, int yy) : x{xx}, y{yy} { }
|
||||||
int get_x() { return x; }
|
int get_x() const { return x; }
|
||||||
void set_x(int xx) { x = xx; }
|
void set_x(int xx) { x = xx; }
|
||||||
int get_y() { return y; }
|
int get_y() const { return y; }
|
||||||
void set_y(int yy) { y = yy; }
|
void set_y(int yy) { y = yy; }
|
||||||
// no behavioral member functions
|
// no behavioral member functions
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user