const/invariant
Derek Parnell
derek at nomail.afraid.org
Wed Dec 5 14:49:56 PST 2007
On Wed, 5 Dec 2007 10:00:28 -0500, Steven Schveighoffer wrote:
> "Denton Cockburn" wrote
>> given a class:
>>
>> class C {}
>>
>> what's the difference between:
>>
>> const C c = new C;
>> and
>> invariant C c = new C;
>>
>> From what I can see, neither are modifiable. So what's different
>> (D2.008).
>
> const class references can be used to call const member functions, but
> cannot call normal member functions or invariant member functions.
>
> invariant class references can be used to call const or invariant member
> functions, but not normal member functions.
>
> normal class references can call normal member functions and const member
> functions, but not invariant member functions.
Thanks Steve, I guess this should be made clearer in the documentation.
Maybe a table such as ...
"Can Call" Table:
Member Function
Instance Declaration+----------------------------+
-------------------| normal | const | invariant |
----------+--------+-------+-----------+
normal | Y | Y | N |
----------+--------+-------+-----------+
const | N | Y | N |
----------+--------+-------+-----------+
invariant| N | Y | Y |
----------+--------+-------+-----------+
--
Derek
(skype: derek.j.parnell)
Melbourne, Australia
6/12/2007 9:41:44 AM
More information about the Digitalmars-d-learn
mailing list