Jump to content
  • Advertisement
Sign in to follow this  
yacwroy

C++: Returning templated class member type.

This topic is 3679 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.

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!