R
Rahul
Hi Everyone,
I was wondering about references to functions, so i tried this,
int (& p[10]) (); // doesn't work as array of references is
illegal as memory is not allocated for references,
next, i tried a single reference to the function,
int ( & p ) ();
int incomplete_function(void)
{
// #error *** Nigel - Function incomplete. Fix before using ***
printf("testing testing testing done...\n");
return (0);
}
int sample(void)
{
printf("sample\n");
return(0);
}
int main()
{
int ( & p) ();
p = incomplete_function;
p();
p = sample;
p();
return(0);
}
and it works fine and both the functions are called, but i expected
the reference to be a constant pointer which can't be declared, in
fact i expected a compilation error in the declaration of the
reference p as it is not initialized over here, is reference to
function legal? what does the standard say about this?
Thanks in advance!!!
I was wondering about references to functions, so i tried this,
int (& p[10]) (); // doesn't work as array of references is
illegal as memory is not allocated for references,
next, i tried a single reference to the function,
int ( & p ) ();
int incomplete_function(void)
{
// #error *** Nigel - Function incomplete. Fix before using ***
printf("testing testing testing done...\n");
return (0);
}
int sample(void)
{
printf("sample\n");
return(0);
}
int main()
{
int ( & p) ();
p = incomplete_function;
p();
p = sample;
p();
return(0);
}
and it works fine and both the functions are called, but i expected
the reference to be a constant pointer which can't be declared, in
fact i expected a compilation error in the declaration of the
reference p as it is not initialized over here, is reference to
function legal? what does the standard say about this?
Thanks in advance!!!