On Thursday, 22 October 2015 at 11:02:05 UTC, DarkRiDDeR wrote:

This variant works strangely. Example:

abstract class Addon
{
        public string name = "0";
}
class Users: Addon
{
        override
        {
                public string name = "USERS";
        }
}
static final class Core
{
        static:
                public Addon[] activated;
                public Users users;
                
                public void activate()
                {
                        users = new Users;
                        activated = [new Users, new Users];
                }
}

Core.activate();
writeln(Core.users.name ~ "\n"  ~ Core.activated[1].name);

Out:
USERS
0

First of all, the code does not compile with override. It is impossible to override a data. Override should be removed. The reason it works this way is that the first access is to base class data while the second is to the derived data member.

Reply via email to