Differences between these two pointers

Hello,

I'm going through some interesting exercises and would like to ask a bundle of questions as I go through the problems.

Here is my first question: what is exactly the difference between:

1
2
3
4
5
6
7
8
9
10
//1.cpp

int main ()
{
int *k=0;

const int* const &i=k; //*
// and
const int * const i=k; //**
}


both compile and seem to be valid, but how exactly?. How would one in words say what * is? Is it a dereferenced constant pointer pointing to a constant?

** is just a constant pointer pointing to a constant integer. Meaning, it is also a null pointer.

Also, when one complies with g++ c- 1.cpp. Would there be any issue with the object file?
* is a reference to const pointer to a const int.
Ah yes. Thank you.

Next question:

would

const double f();

be legitimate? Does the const do anything? I would say no since after every time the function is called the function is terminated and the memory in the stack is removed. Is that correct?
Yes. It's legal, but it doesn't make a difference.
Last edited on
Topic archived. No new replies allowed.