c++ - typedef function pointer that takes argument ClassName* before defining ClassName? -
i have following situation:
typedef void (*f_pointer)(classname*); class classname { public: f_pointer f; }
this happens because instance of classname needs pass pointer client. however, if write things in order, complains classname not declared, whatnot. however, if switch them around, complains f_pointer not being declared when declare instance in class.
so maybe i'm missing simple here, how accomplish this?
forward declaration:
class classname; typedef (*f_pointer)(classname*); class classname { public: f_pointer f; }
or shorter:
typedef (*f_pointer)(class classname*); // implicit declaration;
Comments
Post a Comment