What does C++ do better than D? - StackOverflow.com

Walter Bright newshound2 at digitalmars.com
Mon Aug 1 17:29:05 PDT 2011


On 8/1/2011 5:07 PM, Jonathan M Davis wrote:
> You do get some gains from const in C++, but it's pretty much all gained by
> convention. It _is_ better than just comments in that the compiler will
> complain if you break the convention, forcing you to explicitly break it (e.g.
> via casting or mutable), but ultimately, it doesn't enforce much. I do believe
> that it enforces enough that it's worth having, but it obviously doesn't
> provide the guarantees that D's const does.

Any code at any time can modify a mutable member of a const object, without even 
bothering with the nicety of a cast. The notion that C++ "supports" logical 
const is without merit.




More information about the Digitalmars-d mailing list