Jump to content
  • Advertisement
Sign in to follow this  
ricekrispyw

typedef problem [SOLVED]

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

I have a class like so:

class blabla { public: ... protected: typedef std::map<String, GameObject> GameObjectList; };

Then I try to use that like this, in a function definition for class blabla:
GameObjectList::iterator it = mObjects.find( name );
but VC++ .NET is yelling at me saying that GameObjectList is not a class or namespace. What's up with that!? I'm just coming from VC++6, where that type of thing worked. I don't know if it's because of the updated standards, or if I did something wrong I'm not catching, or what. If someone could tell me what the matter is, I'd appreciate it. Thanks. [Edited by - ricekrispyw on August 11, 2005 10:22:18 PM]

Share this post


Link to post
Share on other sites
Advertisement
No,

You have to do this


typedef std::map<String, GameObject>::iterator GameObjectListIterator;

ace

Share this post


Link to post
Share on other sites
It's something i think i found out myself because it didnt work like yours, i could be wrong though.

ace

Share this post


Link to post
Share on other sites
Quote:
Original post by ricekrispyw
I have a class like so:



class blabla
{
public:
...
protected:
typedef std::map<String, GameObject> GameObjectList;
};



I do this all the time.

This is crazy, but maybe you don't have


#include <map>


Share this post


Link to post
Share on other sites
Quote:
Original post by ace_lovegrove
No,

You have to do this


typedef std::map<String, GameObject>::iterator GameObjectListIterator;

ace


No you don't. I do it the way the OP demonstrated all the time. In fact, i'm in the middle of doing the very same thing ATM.

-me

Share this post


Link to post
Share on other sites
Quote:
Original post by ace_lovegrove
Hold on:

This isnt right.

GameObjectList::iterator it = mObjects.find( name );

GameObjectList is a type not an object so:

GameObjectList myList;

myList::iterator it = mObjects.find( name );

Should be ok.

ace


No, :: is used on types to access inner types. What do you think list::iterator is?

Share this post


Link to post
Share on other sites
I just deleted that post haha, i realised i was talking rubbish, trying to do to o many things at once here.

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!