所以我有這樣一個類:在一個類中有「typedef void FuncCharPtr」如何提供使用非靜態函數的typedef函數?
class IGraphElement{
// We should define prototype of functions that will be subscribers to our data
typedef void FuncCharPtr(char*, int) ;
public:
// Function for adding subscribers functions
void Add(FuncCharPtr* f)
{
//...
}
};
和其他類一樣
#include "IGraphElement.h"
class simpleRendererGraphElement : public IGraphElement
{
public:
IGraphElement* charGenerator;
// we owerrite init
void Init(IGraphElement* CharGenerator)
{
charGenerator = CharGenerator;
//we can to subscribe some function to our data generator
charGenerator->Add(renderCastedData); // and here we receive C3867
}
void renderCastedData(char* castedChar, int castedCharLength) // our event system receives functions declared like void FuncCharPtr(char*, int) ;
{ }
};
我們爲什麼錯誤C3867以及如何解決它沒有制定職能靜態的?
'FuncCharPtr'是一個誤稱:它根本不是一個指針類型,它是一個函數類型。指針類型看起來像'typedef void(* FuncCharPtr)(char *,int);'。 –