On Sunday, 20 March 2016 at 09:53:07 UTC, szymski wrote:
Ok, I understand now, thanks. I used C# a lot before and there
default initialization worked like per instance initialization.
Yes, I assumed you were thinking of C# or Java classes with this.
When coming to a new language, it's natural
On Sunday, 20 March 2016 at 02:21:51 UTC, Mike Parker wrote:
On Saturday, 19 March 2016 at 20:24:15 UTC, szymski wrote:
class A {
B b = new B();
}
This is *default* initialization, not per instance
initialization. The compiler will create one instance of B and
it will become the d
On Saturday, 19 March 2016 at 20:24:15 UTC, szymski wrote:
class A {
B b = new B();
}
This is *default* initialization, not per instance
initialization. The compiler will create one instance of B and it
will become the default initializer of b in *every* instance of
A. You can ver
On 19.03.2016 21:24, szymski wrote:
In my opinion &a.b.variable should give different addresses for each
instance of A, because it's not static. What am I doing wrong? Thanks in
advance.
The As are different, but they all reference the same B. Initialize b in
a constructor instead.
Hello!
I'm having a big problem with class members. I'm kinda new to D,
so this may be my fault, but look at the following code:
import std.stdio;
class B {
int variable;
}
class A {
B b = new B();
}
void main()
{
// Create 10 instances of A
foreach(i; 0 ..