Added 'C_C++/getter_example.cpp'

This commit is contained in:
anon 2024-07-22 19:39:19 +02:00
parent 2f931de4a7
commit 68ebfce64a

29
C_C++/getter_example.cpp Normal file
View 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() { ; }