Inheritance problem

Andrej Mitrovic andrej.mitrovich at gmail.com
Mon Feb 14 07:52:41 PST 2011


On 2/14/11, Steven Schveighoffer <schveiguy at yahoo.com> wrote:
> What's wrong with:
>
> class Foo {
>      private int _x, _y;
>      this(int x, int y) {
>          _x = x;
>          _y = y;
>      }
>      int sumXY() {
>          return _x + _y;
>      }
> }

Nothing! But the OP asked why it's possible to access the private
state of a class if the code that accesses it is in the same module as
the class. So I just threw in an example (which admittedly doesn't
make much sense, and personally I don't like to access private state
outside the class).


More information about the Digitalmars-d-learn mailing list