Advertisement Jump to content
Sign in to follow this  

templates and stl iterator syntax error?

This topic is 4852 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

#include <vector>
#include <map>
#include <utility>

template <class T>
class test
		std::map<int, T*> thingA;
		std::map<int, float>::iterator thingB_works;
		std::map<int, T*>::iterator thingC_fails;
compiling with gcc 3.4 gives: test.cpp:11: error: expected `;' before "thingC_fails" I know its an obvious error but I've looked at it so long I've lost the will to live :) please end my suffering!!

Share this post

Link to post
Share on other sites
The iterator used :: to get at a nested type of a type dependent on a template parameter. The typename keyword is required to tell the compiler you want to interpret the result of the :: as a type rather than a value.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!