Hi Narue,
Ive started your tutorial on pointers and had a few questions about it if you don't mind.
1) You talked about the fact that a function has an adres itself and that you can call a function threw it's adres. This I understand, as I tried it out wether I could print the adres of a function a did this as follow:
void function(int, int)
{
...
}
int main()
{
...
cout<< function <<endl;
...
}
This worked as it should, thing is, I tried this out aswell with &function and *function and those two gave me the exact adres.
Question is, are all three correct possibilities to obtain the functions adres?
2) I tried out the example you showed about pointers to functions and had a problem that I got two errors, they stated the following:
C:\Program Files\Microsoft Visual Studio\MyProjects\VoorbeeldenInternet\PointersTutorialByNarue\Testing.cpp(39) : error C2440: 'initializing' : cannot convert from 'const void *' to 'const int *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
wich is related to this piece of code:
int compare ( const void *a, const void *b )
{
const int *ia = a;
const int *ib = b;
...
}
Now, I understand what the error message is saying and I changed the code so that the parameter const void *a, get's cast like this:
const int *ia = static_cast <const int*> (a);
This way it works, but, I kept wondering wether this was not related towards either the compiler (MS VC 6.00) I'm using or some other reason :?:
Anyway, thanks for the superb tutorial, Ive allready learned alot ;)