Sign in to follow this  

Can't compile template class

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Actually, i managed to figure it out right after i posted. =)
Aparently i had to put the typedef above the constructor, for obious reason when i think about it...but i have no clue why i got the error on T =/

Thanks for the reply though Steve =)

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this