Jump to content
  • Advertisement
Sign in to follow this  
janta

typedef inside class

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

Hi
I looked into my C++ standard book but couldn't find anything specific to this situation (in the "typedef" section)


class A
{
public:
typedef char MyType; // intendedly private
};

class B : public A
{
public:

typedef float MyType;

void PrintSize()
{
printf("%d", sizeof(MyType)); // prints 4, ok
printf("%d", sizeof(A::MyType)); // prints 1, ok
}
};


What would be the standard here?
1) Is "Overriding" a typedef from a base class permitted at all? (visual studio accepts it)
2) If it is, does it follow the usual rules of overriding? (say, like a class member)


What do you think?

Thanks for your help.

Share this post


Link to post
Share on other sites
Advertisement
That's OK. There are two typedeffed names at two different scopes (A::MyType and B::MyType).

No overriding involved. Only methods can be overridden.

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!