It seems you are mixing C ++ classes with D classes.
D classes are always passed by reference (unlike, say, C ++ classes), and PerformanceCounter t does not allocate a class on the stack, but simply a pointer to it.
This means that t set to null , because, well, null is the default initializer for pointers - hence, an error.
EDIT: You can think of the D Foo class as C ++ Foo* .
If you want this to be allocated on the heap, you can try using structures instead of them - they can also have methods, like classes. However, they have no inheritance.
Tim ฤas
source share