jeans chen
we've got them by the balls

#include <iostream>
#include <math.h>
#include <stdlib.h>

using namespace std;

int main()
{
    double (*fp[2])(double) = {sqrt,fabs};//[]优先级大于*
    for(int i = 0;i < 2;i++)
    {
        cout << fp[i](9) << endl;
    }
    for(int i = 0;i < 2;i++)
    {
        cout << (*fp[i])(9) << endl;//[]优先级大于*
    }
    for(int i = 0;i < 2;i++)
    {
        cout << ((*fp)[i])(9) << endl;//[]优先级大于*
    }

}

 

函数指针.cpp:20: warning: pointer to a function used in arithmetic

试题$ ./1
3
9
3
9
3//估计这个地方直接把数组的第一个元素拿来用了,且没有移动指针了。
3

 

 

posted on 2013-11-18 17:04  jeans chen  阅读(223)  评论(0编辑  收藏  举报