October 02, 2003 Re: constructors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dario | In article <blfime$2mnf$1@digitaldaemon.com>, Dario wrote: > Antti Sykäri: >> This would, actually, be different from ordinary methods. In D, overriding function <func> in a derived class does not hide overloaded <func>'s from the parent class. This is unlike C++... > > No, D's like C++. > > module test; > class A > { > void func() {} > void func(int n) {} > } > class B > { > void func(int n) {} > } > void main() > { > B b = new B; > b.func(); > } > > test.d(14): function func (int a) does not match argument types () I could've sworn that a) this was discussed before and then it was noted that D works differently than C++ and b) that I tested it and it worked! (Even with class B inheriting class A, which you forgot here). Strange... I feel really demented now. -Antti |
Copyright © 1999-2021 by the D Language Foundation