{
}
Void main ()
Void (* p) ();
P=f
}
CodePudding user response:
P is defined as a no parameters and return a pointer to the function ofAnd f is a parameter that can compile, but call, what do you call?
CodePudding user response:
The some space, semicolon, Chinese and English parentheses, bracketsCodePudding user response:
#include
#include
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
# pragma argsused
using namespace std;
Void f (int xx)
{
//cout & lt; <"X=" & lt;Cout & lt; <"F (int x) called... "& lt; }
Int _tmain (int arg c, _TCHAR * argv [])
{
Void (* p) ();
P=(void (*) ()) f;//no type cast to
P ();
system("PAUSE");
return 0;
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
CodePudding user response:
Forced to transfer to no arguments function or use consistent definition and call function, handling of the function name, unlike C, C + + void f (int xx) function of the star is processed by a compiler to void f_xx to distinguish the overloaded function (),//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
# pragma hdrstop
#include
#include
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
# pragma argsused
using namespace std;
Void f (int xx)
{
Cout & lt; <"X=" & lt;Cout & lt; <"F (int x) called... "& lt; }
Int _tmain (int arg c, _TCHAR * argv [])
{
Void (* p) (int x);
P=f;
P (1010);
system("PAUSE");
return 0;
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --