Jump to content
  • Advertisement
Sign in to follow this  
yacwroy

C++: Returning templated class member type.

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

Ok this one should possibly be in the beginners section :( What on earth is wrong with this?
#include <vector>
template <typename T>
std::vector<T>::iterator bar();
int main() {}

G++ ERROR: 3: error: expected constructor, destructor, or type conversion before ‘bar’ It seems there's nothing special about iterator, making a generic template class with a type doesn't work either. Returning a std::vector<T> obviously works. Replacing bar(); with bar; doesn't help. Thanks for all help.

Share this post


Link to post
Share on other sites
Advertisement
template <typename T>
typename std::vector<T>::iterator bar();


You have to tell the compiler that the 'iterator' member is always a type.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!