On Sunday, 16 April 2023 at 08:38:55 UTC, Ali Çehreli wrote:
On 4/16/23 00:46, Skippy wrote:
> I wish D had value type classes as well.
That cannot work due to the slicing problem.
C++ cannot have value type classes either for the same reason.
The difference there is that the enforcement is
On Sunday, 16 April 2023 at 06:39:17 UTC, Mike Parker wrote:
`t1` is default-initialized, so it's null.
test t1, t2 = new test();
silly me. I should have picked that up myself. thanks.
Ditto for t3. Classes are reference objects, not value objects,
so you must explicitly instantiate
Anyone wanna try converting this C++ example to D?
(I tried, but getting nowhere.. so far).
// --- C++ example - working -
#include
using std::cout;
class test
{
private:
int objNo;
static int objCnt;
public:
test()
{
objNo = ++objCnt;
}
~test()
{