任何人都可以幫助我這個簡單的代碼?函數指針錯誤
#include <iostream>
using namespace std;
void testFunction(){
cout<<"This is the test function 0"<<endl;
}
void testFunction1(){
cout<<"This is the test function 1"<<endl;
}
void testFunction2(){
cout<<"This is the test function 2"<<endl;
}
void (*fp[])()={testFunction,testFunction1,testFunction2};
int main(){
//fp=testFunction;
(*fp[testFunction1])();
//cout<<"Addrees of the function pointer is:"<<*fp;
}
我收到以下錯誤:
error: invalid types `void (*[3])()[void()()]' for array subscript|
那可真是邪的東西,順便說一句。 – 2010-03-31 08:46:36