Sign in to follow this  
Akusei

typedefs, classes and scope

Recommended Posts

I have a header file for a particular class that contains the class definition as well as a couple typedefs like below:

[code]
typedef std::map<std::string, sf::Image> ImageMap;
typedef std::map<std::string, sf::somethingelse> DifferentMap;

typedef struct ResourceHeader
{
char n1;
char n2;
char n3;
};

class TestClass
{
private:
//blah

public:
//blah
};
[/code]

The 3 typedefs in the above example are used only by the functions in that class, so would be it proper to declare the whole thing like this:

[code]
class TestClass
{
private:
typedef std::map<std::string, sf::Image> ImageMap;
typedef std::map<std::string, sf::somethingelse> DifferentMap;

typedef struct ResourceHeader
{
char n1;
char n2;
char n3;
};

//blah

public:
//blah
};
[/code]

And that is my question, thanks.

Share this post


Link to post
Share on other sites
Thanks for the responses. I thought nesting would be the way to go, but I didn't know if it was excessive or not. Also, thanks Cornstalks for letting me know about the unnecessary typedef on the struct; I didn't know that.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this