Jump to content

  • Log In with Google      Sign In   
  • Create Account


Template classes in container


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 RAZORUNREAL   Members   -  Reputation: 567

Like
0Likes
Like

Posted 22 June 2006 - 11:03 PM

I'm having problems creating a map of templated classes. It seems to have no problem with the map itself, but doesn't like iterators for it. Here's as simple as I can get it:
template<class T>
class A
{
};

template<class T>
class B
{
	std::map<int, A<T> >::iterator iter; // error: expected ';' before "iter"
};

It's weird, because I seem to be able to use iterators returned by the map. I guess I'm just declaring them wrong somehow. Oh, and I'm using mingw. Thanks!

Sponsor:

#2 jflanglois   Members   -  Reputation: 1018

Like
0Likes
Like

Posted 22 June 2006 - 11:07 PM

You probably need to add typename to your iterator declaration:

typename std::map< int, A< T > >::iterator iter;


jfl.

#3 RAZORUNREAL   Members   -  Reputation: 567

Like
0Likes
Like

Posted 22 June 2006 - 11:15 PM

Awesome! That works, but why is it needed? Is it ambiguous in some way without it?

#4 jflanglois   Members   -  Reputation: 1018

Like
0Likes
Like

Posted 22 June 2006 - 11:21 PM

I can't find it anymore, but there was a great article about templates and dependent names. This looks like a good substitution, though.


jfl.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS