函数指针参数
声明了一个带参数的函数指针void(*ptr)(int s))
现在调用的时候出现[C++ Error] Unit1.cpp(21): E2451 Undefined symbol 's'
请问如何调用把参数传入函数func(int s)中?
[code=C/C++]
void caller(void(*ptr)(int s))
{
ptr(s); /* 调用ptr指向的函数 */
}
void func(int s)
{
ShowMessage(IntToStr(s));
}
int test()
{
caller(func); /* 传递函数地址到调用者 */
}
[code]
[解决办法]
void caller(void(*ptr)(int),int s)
{
ptr(s); /* 调用ptr指向的函数 */
}
[解决办法]
请参考:
函数指针的几种用法