Sign in to follow this  
janta

typedef inside class

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

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