在C++中,讓我們說,我有以下的頭文件:多類的靜態成員函數全部用相同的參數和返回
class Foo {
static int func0 (int, int);
static int func1 (int, int);
static int func2 (int, int);
static int func3 (int, int);
};
反正是有通過的typedef做到這一點?
我想:
class Foo {
typedef int(*func)(int, int);
static func func1;
static func func2;
static func func3;
static func func4;
};
,然後在CPP文件
int Foo::func1(int a, int b) { return a + b; }
,但我得到的錯誤:
Redefinition of func1 as different kind of symbol
你試圖解決什麼問題?我強烈懷疑有一種實現你想要的簡單方法,但這取決於你的總體目標是什麼。 –
您的問題可能在於您的代碼設計。發表真正的例子與評論什麼功能應該做的。 – Thomas