Re: Constructor is not callable using argument types

2017-08-08 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 8 August 2017 at 06:03:06 UTC, Nrgyzer wrote: Hi guys, I've the following code: abstract class a {} class b : a { this(a* myAttr = null) {} } class c : a { this(a* myAttr = null) {} } void main() { auto myb = new b(); auto myc = new c(); } DMD says "Constructor c.this(a*

Constructor is not callable using argument types

2017-08-08 Thread Nrgyzer via Digitalmars-d-learn
Hi guys, I've the following code: abstract class a {} class b : a { this(a* myAttr = null) {} } class c : a { this(a* myAttr = null) {} } void main() { auto myb = new b(); auto myc = new c(); } DMD says "Constructor c.this(a* myAttr = null) is not callable using argument types (b*)".

Re: constructor is not callable using argument types ()

2012-12-10 Thread Suliman
Thanks! But if I have a lot of property like^ string name int age it's not good to specify all of them in paranceses: auto file = new FileName(test.txt, 21, ETC); How can I specify them in another way?

Re: constructor is not callable using argument types ()

2012-12-10 Thread bearophile
Suliman: But if I have a lot of property like^ string name int age it's not good to specify all of them in paranceses: auto file = new FileName(test.txt, 21, ETC); How can I specify them in another way? There are several ways to help that. A simple way is to use default arguments:

Re: constructor is not callable using argument types ()

2012-12-08 Thread Suliman
Could you help me with this simple code. I still playing with constructor, but I can't understand how to use it. http://www.everfall.com/paste/id.php?6n72xxxkz7ba

Re: constructor is not callable using argument types ()

2012-12-08 Thread bearophile
Suliman: Could you help me with this simple code. I still playing with constructor, but I can't understand how to use it. http://www.everfall.com/paste/id.php?6n72xxxkz7ba You have code like this: class FileName { string name; this(string name) { this.name = name; }

constructor is not callable using argument types ()

2012-12-06 Thread Suliman
I am learning D classes and I am getting error when I am try to make instance of class. erorr: C:\code\main.d(9): Error: constructor GetFileName.GetFileName.this (string name) is not callable using argument types () http://www.everfall.com/paste/id.php?xie09xz9upth

Re: constructor is not callable using argument types ()

2012-12-06 Thread Simen Kjaeraas
On 2012-12-06, 20:17, Suliman wrote: I am learning D classes and I am getting error when I am try to make instance of class. erorr: C:\code\main.d(9): Error: constructor GetFileName.GetFileName.this (string name) is not callable using argument types ()

Re: constructor is not callable using argument types ()

2012-12-06 Thread Suliman
Am I right that my variant of code would be valid for C#? How can I assign value to name in such manner?

Re: constructor is not callable using argument types ()

2012-12-06 Thread Suliman
When I should use keyword this? I dropped it from my class and now I can make instance of class without in sych way: auto file = new GetFileName(); file.name = test;

Re: constructor is not callable using argument types ()

2012-12-06 Thread Simen Kjaeraas
On 2012-12-06, 20:48, Suliman wrote: When I should use keyword this? I dropped it from my class and now I can make instance of class without in sych way: auto file = new GetFileName(); file.name = test; Indeed. If you have not defined a constructor, the language defines one for you, which