[Issue 3393] New: illegal to refer to 'this' implicitly or explicitly
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Oct 13 07:44:57 PDT 2009
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: nobody at puremagic.com
ReportedBy: dfj1esp02 at sneakemail.com
--- Comment #0 from Sobirari Muhomori <dfj1esp02 at 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: -------
More information about the Digitalmars-d-bugs
mailing list