Hello David W,
> You can always use local variables in member functions,
> but they're local and can't be seen outside.
But for the calculations result ofcourse :-)
That was what I actully tried to ask: does that trailing 'const' also signal
nothing dynamic will happen in the function (including juggling of some
numbers to generate a result). I cannot really imagine that would be the
case (it would be pretty daft), but I had to ask.
> means you can't change what is at the location pText
> in memory - ie you can't replace the content "Hello"
> at that point.
Yes, I think I understood that one. For a variable that is. I had nu clue
how it would work with a function-result though.
> Note the *two* uses of const in the second one.
Now I'm again confused. You are using a 'const' modifier after the
variable-name, while David L. gave me a link showing both of them before it
:
[yours] const int *pointer_to_x() const { return &x; }
[His link] const <type of pointer>* const <name of pointer>
Does that mean you could get actually three 'const' modifiers in there ?
[mixing] const int *const pointer_to_x() const { return &x; }
No clue what this would result in though .... :-\
If not, how is yours different from his example ? They seem to do the same
thing.
> I regard becoming familiar with the uses of 'const' as one of
> the most important things anyone learning C or C++ must do.
:-) Than I'm lucky I noticed them this early in my wrestling with some
source-code, ain't I ?
> If all the things which should be 'const' *are* 'const' then you can
> maintain vast chunks of code, knowing that they can't corrupt your
> data, because the compiler would have given you an error message.
Yes, that will be very helpfull indeed.
Regards,
Rudy Wieser
NF_at.1347$Wa2...@fx04.fr7...