September 27, 2006 wrong function overload | ||||
---|---|---|---|---|
| ||||
import std.stdio; enum COLOR{RED}; enum TYPE{SOFT_TOP}; class Car{ int val; void roof( COLOR c) { val= 1; } void roof(TYPE t, int i) { val= 2; } } void main(){ auto mycar= new Car; mycar.roof( TYPE.SOFT_TOP); // should not compile writefln( mycar.val); // should print 2 } |
September 29, 2006 Re: wrong function overload | ||||
---|---|---|---|---|
| ||||
Posted in reply to Karen Lanrap Attachments: | Karen Lanrap schrieb am 2006-09-27: > import std.stdio; > enum COLOR{RED}; > enum TYPE{SOFT_TOP}; > class Car{ > int val; > void roof( COLOR c) > { > val= 1; > } > void roof(TYPE t, int i) > { > val= 2; > } > } > void main(){ > auto mycar= new Car; > mycar.roof( TYPE.SOFT_TOP); // should not compile > writefln( mycar.val); // should print 2 > } Added to DStress as http://dstres.kuehne.cn/nocompile/e/enum_50_A.d http://dstres.kuehne.cn/nocompile/e/enum_50_B.d http://dstres.kuehne.cn/nocompile/e/enum_50_C.d http://dstres.kuehne.cn/nocompile/e/enum_50_D.d http://dstres.kuehne.cn/nocompile/e/enum_50_E.d Thomas |
Copyright © 1999-2021 by the D Language Foundation