D - Getters and Setters with operators
- Russ Lewis (16/16) Aug 21 2001 Another twist on Getters and Setters I just thought of:
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;
Aug 21 2001