Added 'C_C++/getter_example.cpp'
This commit is contained in:
parent
2f931de4a7
commit
68ebfce64a
29
C_C++/getter_example.cpp
Normal file
29
C_C++/getter_example.cpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// @BAKE $@ -o $*.out
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
class Rect {
|
||||||
|
int _w, _h, _area;
|
||||||
|
public:
|
||||||
|
void set_w(int w) {
|
||||||
|
_w = w;
|
||||||
|
area = _w * _h;
|
||||||
|
}
|
||||||
|
void set_h(int h) {
|
||||||
|
_h = h;
|
||||||
|
area = _w * _h;
|
||||||
|
}
|
||||||
|
int area() {
|
||||||
|
return _area;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
class Rect {
|
||||||
|
public:
|
||||||
|
int w, h;
|
||||||
|
int area() {
|
||||||
|
return w * h;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
signed main() { ; }
|
Loading…
x
Reference in New Issue
Block a user