const

Janice Caron caron800 at googlemail.com
Fri Mar 28 01:26:42 PDT 2008


On 27/03/2008, Bill Baxter <dnewsgroup at billbaxter.com> wrote:
> That sounds almost completely wrong to me.  C++ programmers tend to use
>  'const' in their function signatures to document the things that
>  shouldn't change.  That sounds like self-documentation to me.  What do
>  you mean by "rely on convention instead"? Please explain.

    class C
    {
        int ** p;
    }

    void f(const C &c)
    {
        **c.p = 1; // Legal in C++
    }

There is no way to express compiler-checked transitive constancy in C++.



More information about the Digitalmars-d mailing list