Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
July 28, 2003 bug: duplicated constructors | ||||
---|---|---|---|---|
| ||||
This code: class A { this() {} private: this() {} this(int b) { a=b; } int a; } void main() { A x=new A(); } Gives this error: constructor this overloads A () and A () both match argument list for this. Personally, I was expecting something like duplicated constructor or something like that. Or at least I was expecting it to compile just fine since one of the two constructors is private. Right before posting I tried putting the class in a different module (because I remembered friendship and such) and I got the same error. ------------------------- Carlos Santander --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.504 / Virus Database: 302 - Release Date: 2003-07-24 |
July 28, 2003 Re: duplicated constructors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Carlos Santander B. | I'm not sure what the bug is, unless it's just an obscure error message! There are two constructors for A with the same argument list, so it is an error in the program. "Carlos Santander B." <carlos8294@msn.com> wrote in message news:bg240f$t26$1@digitaldaemon.com... > This code: > > class A { > this() {} > private: > this() {} > this(int b) { a=b; } > int a; > } > void main() { > A x=new A(); > } > > Gives this error: constructor this overloads A () and A () both match argument list for this. Personally, I was expecting something like duplicated constructor or something like that. Or at least I was expecting it to compile just fine since one of the two constructors is private. > > Right before posting I tried putting the class in a different module (because I remembered friendship and such) and I got the same error. > > ------------------------- > Carlos Santander > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.504 / Virus Database: 302 - Release Date: 2003-07-24 > > |
July 28, 2003 Re: duplicated constructors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <walter@digitalmars.com> wrote in message news:bg40fp$2seq$1@digitaldaemon.com... | I'm not sure what the bug is, unless it's just an obscure error message! | There are two constructors for A with the same argument list, so it is an | error in the program. | I know it's an error in the program, but it shouldn't compile anyway. The compiler should complain, shouldn't it? ————————————————————————— Carlos Santander --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.504 / Virus Database: 302 - Release Date: 2003-07-24 |
July 28, 2003 Re: duplicated constructors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Carlos Santander B. | "Carlos Santander B." <carlos8294@msn.com> wrote in message news:bg44kp$30p3$1@digitaldaemon.com... > "Walter" <walter@digitalmars.com> wrote in message > news:bg40fp$2seq$1@digitaldaemon.com... > | I'm not sure what the bug is, unless it's just an obscure error message! > | There are two constructors for A with the same argument list, so it is an > | error in the program. > | > > I know it's an error in the program, but it shouldn't compile anyway. The compiler should complain, shouldn't it? Yes, it should. |
Copyright © 1999-2021 by the D Language Foundation