Hello to all,
I'm starting to program in Dlang. I use for the moment the online editor.
I test the following code:
import std;
class User
{
    private string name;
private:
    string firstname;
    int age;
public:
    override string toString()
    {
        return (format("User: %s %s - (%s)", this.name, this.firstname, this.age));
    }
};
void main()
{
    auto bob = new User();
    bob.name = "Bob";
    bob.firstname = "McDean";
    bob.age = 15;
    writeln(bob);
}
and I don't understand why I can modify private members from outside my class.
I had understood that it was required to create accessors to have this behavior.
Thanks in advance to all for your welcome and your answers.
Christophe__c
 Permalink
Permalink Reply
Reply