Jump to content
  • Advertisement
Sign in to follow this  
angrybob

templates and stl iterator syntax error?

This topic is 4669 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
{
	protected:
		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
Advertisement
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 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!