I have two questions:
Q1) Are function names themselves pointers?
If these are pointers, then what values ββare stored in them?
Otherwise, if they are not pointers, then what are they and what values ββare stored in them?
If we assume that function names are pointers. Then:
void display(){...} int main () { void (*p)(); **p=display; //Works (justified**, because we are assigning one pointer into another) **p=&display; //Works (Not justified** If function name is a pointer (let say type*) , then &display is of datatype : type**. Then how can we assign type** (ie &display) into type * (ie p)??) **p=*display; //Works (Not justified** If function name is a pointer ( type *) ,then, how can we assign type (ie *display) into type * (ie p) ?? ) }
Yet again,
cout<<display<<";"<<&display<<";"<<*display;
Prints something like:
0x1234; 0x1234; 0x1234
[1234 is just an example]
[OMG! How is this possible? How to indicate the address of the pointer, the address to which it points, and the value at the specified address are all the same? ]
Q2) What value is stored in a user-defined function pointer?
Consider an example:
void display(){...} int main() { void (*f)(); f=display; f=*f;
[The first two outputs are justified ... But how can the value in the pointer (the address it points to) be equal to the value stored at the specified address? ]
Again:
f=*********f; // How can this work?
I searched it on the Internet, but all the information that is available is about using and example code to create function pointers. None of them says that they are, and how they differ from ordinary pointers.
So, I have to miss something very basic. Please indicate to me what I am missing. (Sorry for my ignorance becoming a newbie.)