Possible Duplicate:
Why is my return type meaningless?
Hi, I'm confused about a particular const conversion. I have something like
// Returns a pointer that cannot be modified,
// although the value it points to can be modified.
double* const foo()
{
static double bar = 3.14;
return &bar;
}
int main()
{
double* const x = foo(); // fine
const double* y = foo(); // eh?!
return 0;
}
When I compile this on MSVS 2008 (Express) there is no error, but it seems to me like there should be. The meaning behind x and y are quite different, so it does not seem like there should be this implicit conversion. So is this an issue with the compiler (unlikely), or my understanding of the const-ness involved here (quite likely).