wimalopaan
11/22/2008 8:37:00 AM
On 22 Nov., 09:23, wimalopaan <wilhelm.me...@fh-kl.de> wrote:
> On 22 Nov., 08:25, Alan Johnson <aw...@yahoo.com> wrote:
>
>
>
> > wimalopaan wrote:
> > > #include <iostream>
>
> > > char a = 'b';
> > > void foo(const char** ccPtr) {
> > > *ccPtr = &a;
> > > }
>
> > > int main() {
> > > const char x = 'a';
> > > const char* cPtr = &x;
>
> > > foo(&cPtr); // &cPtr is of type const char**
>
> > > std::cout << "x: " << x << std::endl;
> > > // oops!!!
> > > }
>
> > I don't think there are any errors in this code. Are you getting a
> > compile error of some sort? A runtime error?
>
> > --
> > Alan
>
> Well, no compile error, but "sort of" runtime error.
>
> What I mean is: why can I change the const-variable x?
Oh, my fault - it was a bit too early this morning.
Please forget the discussion!