What's the correct way of creating an instance of class in D?

Siarhei Siamashka siarhei.siamashka at gmail.com
Thu Nov 3 05:41:06 UTC 2022


On Thursday, 3 November 2022 at 05:10:06 UTC, matheus wrote:
> https://dlang.org/spec/class.html

Thanks for the link and also thanks for confirming that you have 
no clue what's going on. I think that what actually happens is 
that the D code

```D
   A a2;
   a2.foo();
```

is roughly equivalent to C++

```C++
   A *a2 = NULL;
   a2->foo();
```

I see two problems here. First, the D language documentation is 
incomplete and does not cover this particular syntax. And second, 
D language is designed (intentionally or accidentally) to be 
hostile to the C++ developers trying to learn it. This particular 
issue is known as https://en.wikipedia.org/wiki/False_friend


More information about the Digitalmars-d-learn mailing list