• 12
• 15
• 19
• 27
• 9

# Can't compile template class

This topic is 4293 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi! I'm happly coding along on my new engine, which base it's core design on the "Enginuity-engine". I was just implementing the functors and i got these errors when trying to compile the code.
error C2226: syntax error : unexpected type 'T'
see reference to class template instantiation 'CFunctor<T>' being compiled
error C2334: unexpected token(s) preceding ':'; skipping apparent function body

The code for the functor class looks like this
template<class T>
class CFunctor : public CFunctorBase
{
public:
CFunctor(T *_ptr, FuncType _func) : ptr(_ptr), func(_func) {}

inline void operator ()()
{
(this->ptr->*func)();
}

AUTO_SIZE;

protected:
typedef void (T::*FuncType)();

protected:
T *ptr;
FuncType func;
};


...and i get the error on the line with the constructor ( CFunctor(T *_ptr, FuncType _func) : ptr(_ptr), func(_func) {} ). I have never encountered this problem before. Anyone able to help out? I include a few .h files before defining the class which are template classes, but this shouldn't be a problem, right?

##### Share on other sites
class CFunctor : public CFunctorBase
Should be:
class CFunctor : public CFunctorBase<T>

I think, I could be wrong.