Jump to content
  • Advertisement
Sign in to follow this  
Android_s

Can't compile template class

This topic is 4449 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
Advertisement
class CFunctor : public CFunctorBase
Should be:
class CFunctor : public CFunctorBase<T>

I think, I could be wrong.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!