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*
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*)".
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?
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:
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
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;
}
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
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 ()
Am I right that my variant of code would be valid for C#?
How can I assign value to name in such manner?
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;
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
11 matches
Mail list logo