August 21, 2001 Getters and Setters with operators | ||||
---|---|---|---|---|
| ||||
Another twist on Getters and Setters I just thought of: class Foo { int bar; public: int bar() { return bar; }; void bar(int x) { bar = x; }; }; This works fine for some code: Foo foo; foo.bar = 3; int x = foo.bar; But we also need to handle: foo.bar += 7; Which means that the compiler will need to expand it as foo.bar = foo.bar + 7; |
Copyright © 1999-2021 by the D Language Foundation