http://d.puremagic.com/issues/show_bug.cgi?id=3393

           Summary: illegal to refer to 'this' implicitly or explicitly
           Product: D
           Version: 2.032
          Platform: x86
               URL: http://www.digitalmars.com/d/2.0/class.html#Constructo
                    r
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid, spec
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: dfj1es...@sneakemail.com


--- Comment #0 from Sobirari Muhomori <dfj1es...@sneakemail.com> 2009-10-13 
07:44:56 PDT ---
Spec reads: 3. It is illegal to refer to this implicitly or explicitly prior to
making a constructor call. Although it's allowed.

---
class A
{
    int a;
    this(){ M(); this(1); }
    this(int b){ a=b; }
    void M(){ writeln("A.M"); }
}

class B:A
{
    int b;
    this(){ M(); super(); b=5; }
    override void M(){ writeln("B.M ",b); }
}

int main()
{
    auto b=new B();
    b.M();
    return 0;
}
---

output is
---
B.M 0
B.M 0
B.M 5
---

We see how virtual method is called prior to constructor calls and overridden
method from derived class is called from the constructor of the base class
(called on not yet constructed object).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to