digitalmars.D.learn - Calling method on new instance of class
Hi, Sorry if I'm labouring an old point but is there a reason why I can't do the following: class A { public this() {} public void doSomething() {} } int main() { new A().doSomething(); // can't do this } Thanks.
Jun 17 2005
pmoore wrote:Hi, Sorry if I'm labouring an old point but is there a reason why I can't do the following: class A { public this() {} public void doSomething() {} } int main() { new A().doSomething(); // can't do this } Thanks.You can, it's just a precedence problem: (new A()).doSomething() xs0
Jun 17 2005
Ah. Thank you. In article <d8ugjo$19e3$1 digitaldaemon.com>, xs0 says...pmoore wrote:Hi, Sorry if I'm labouring an old point but is there a reason why I can't do the following: class A { public this() {} public void doSomething() {} } int main() { new A().doSomething(); // can't do this } Thanks.You can, it's just a precedence problem: (new A()).doSomething() xs0
Jun 17 2005