Liste des Groupes | Revenir à cl c |
On 28/11/2024 23:20, Keith Thompson wrote:Bart <bc@freeuk.com> writes:>On 28/11/2024 22:38, Keith Thompson wrote:>Yes, you said that T is an alias for 'const int'. Not sure why you>T x; // defines a readonly variable (which probably needsYou say T is an alias (what, a macro?) for 'const int', you show code
// initialising)
T* y; // defines a variable pointer
>
'const' is out of the picture.
using T, and then you say "'const' is out of the picture". If you
have a point, it escapes me.
Well, can you see 'const' in my example? You can't tell x is readonly
by only looking at this.
wrote "alias". Is it a macro, or a typedef, or something else?
I suggest that hiding "const" behind a macro or typedef is usually a
bad idea. Why did you do it here? Is your example based on real
code, or did you contrive it to be as confusing as possible?
It's to illustrate that the constness of a variable may depend on
something which is remote from its declaration.
>
Which is unlike how it usually works elsewhere.
>
(And if it matters, the alias used a typedef.)
>
For extra confusion, consider this version:
>
T x, *y;
>
The storage for x is read-only; for y it isn't. Or is it the other way
around?
Les messages affichés proviennent d'usenet.