//class.h
typedef double (*ffunct)(double x1, double y1, double x2, double y2);
class Class {
public:
static ffunct myfunct;
static void setFunct();
static double doSomething(double x1, double y1, double x2, double y2);
static void call();
}
//class.cpp
void Class::setFunct(){
Class::myfunct=Class::doSomething;
}
double Class::doSomething(double x1, double y1, double x2, double y2) {
cout << "Hello World" << endl;
}
void Class::call() {
Class::myfunct(1.0,2.0,3.0,4.0);
}
//main.cpp
…
Class::setFunct();
Class::call();
…
運行在Undefined symbols for architecture x86_64: "Class::myfunct", referenced from Class::setFunct, Class::call…
C++的typedef靜態函數指針:未定義的符號
所以PROGRAMM結果我究竟做錯了什麼?