打印

刚开始学c++,函数指针问题!

刚开始学c++,函数指针问题!

小弟最近刚开始学习c++,有一点不太清楚!以前学习C语言时,C里面有讲到函数的指针,感觉很方便!但是最近查了一些C++的资料,好像都没有提到函数指针问题,是不是C++不支持该功能了?把以前的程序输进去也不能编译通过,求解!如果不支持,应该怎样实现同样的功能,谢谢!注:
[code:1]#include <iostream>

int main()
{
    int max();

    int a,b,c;
    //指向函数的指针,该函数返回类型为整数
    int (*p)();

    std::cout<<"Pleanse enter two number:";
    std::cin>>a>>b;

    p=max;
    std::cout<<"the max is "<<(*p)(a,b);
}

int max(int x,int y)
{
    if ( x>y ) return x;
    return y;
}
[/code:1]gcc3.4编译不能通过
Once we dreamt that we were strangers. We wake up to find that we were dear to each other!

TOP

已经搞定了,呵呵!
Once we dreamt that we were strangers. We wake up to find that we were dear to each other!

TOP