From: jo************@yahoo.com (jobseeker)
Newsgroups: comp.lang.c++.moderated
Subject: template and forward declaration
NNTP-Posting-Host: 131.233.150.22
I have defined a class that contains a data member of a function type.
The signature of the function type take a pointer of the class itself
as a parameter:
class Softkey; // forward declaration
typedef int (* pfncOnSelect)(Softkey *key, void *);
class Softkey
{
...
int value;
pfncOnSelect m_OnSelect;
...
};
This class is compiled and run successfully without error. The
problem I have now is that I am trying to modify this class into a
templated class as follows:
template<class Type>
class SoftKey; // forward declaration.
typedef int (* pfncOnSelect)(SoftKey *key, void *);
template<class Type>
class Softkey
{
...
Type value;
pfncOnSelect m_OnSelect;
...
};
Now the compiler complains about syntax error in the typedef line.
I have tried with
template<class Type>
typedef int (* pfncDrawCap)(TestKey *key, void *);
or
template<class Type>
typedef int (* pfncDrawCap)(TestKey<Type> *key, void *);
but I still get an error. Can anyone throw some light into this?