In a templated class I wrote, there is a public typedef for a function
pointer. The class has an instance of the function pointer as a
private member. That pointer is declared as static so I need to
declare an instance of the pointer. So, I tried using the keyword
typename to declare the static member. I don't get any syntax errors
but the pointer's name shows up in an "undefined symbol" error at
compile time. Have a look at this example code and tell me if you can
stop an error.
template <class T>
class XYZ
{
public:
// Function pointer type
typedef int(*funcPtr)(T ,T);
protected:
// Static function pointer
static funcPtr myCallback;
};
// XYZ's static function pointer declaration
typename XYZ<class T>::funcPtr XYZ<class T>::myCallback ;
pointer. The class has an instance of the function pointer as a
private member. That pointer is declared as static so I need to
declare an instance of the pointer. So, I tried using the keyword
typename to declare the static member. I don't get any syntax errors
but the pointer's name shows up in an "undefined symbol" error at
compile time. Have a look at this example code and tell me if you can
stop an error.
template <class T>
class XYZ
{
public:
// Function pointer type
typedef int(*funcPtr)(T ,T);
protected:
// Static function pointer
static funcPtr myCallback;
};
// XYZ's static function pointer declaration
typename XYZ<class T>::funcPtr XYZ<class T>::myCallback ;
Comment