Michiel Helvensteijn wrote:
Andrei Alexandrescu wrote:
So the solution in D would then be to always use struct? No, because
value semantics seems to come at the price of inheritance. Why? C++ seems
to handle inheritance in value types just fine.
I think C++ does not handle inheritance in value types all that well, in
fact the way it deals with the collision is pretty gruesome. It's all
dark corners and dangers and caveats and puzzling behavior.
Walter said something similar. I'm curious, which collision are you
referring to? Which dark corners and dangers and caveats and puzzling
behavior?
Can you explain? Or perhaps refer me to a web location that explains?
Thanks.
The issues are discussed in the book C++ Coding Standards and also in
More Effective C++. Part of the problem is slicing, which you may want
to google for. MEC++ discusses the problem of defining constructors and
particularly copy constructors in hierarchies. Assignment and comparison
are also problematic.
Andrei