Jump to content
  • Advertisement
Sign in to follow this  
snooty

inherited enum

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

Why does the following work? Aren't A::F and B::F different types?
class A
{
public: enum F { F1 };
};

class B : public A
{
};

try
{
	throw A::F1;
}
catch(B::F)
{
	MessageBox(hWnd, _T("caught"), 0, MB_OK); //shown
}

try
{
	throw B::F1;
}
catch(A::F)
{
	MessageBox(hWnd, _T("caught again"), 0, MB_OK); //shown
}

Share this post


Link to post
Share on other sites
Advertisement
B::F actually refers to A::F. Subclassing a type doesn't 'copy' all the functionality of the base class, but it simply extends it.

Share this post


Link to post
Share on other sites
Thank you.

But with the following, the compiler complains:

class A
{
public:
enum F { F1 };

F foo() { return F1; }
};

class B : public A
{
public:
F bar() { return foo(); }
};



It seems there is a double standard here... :(

EDIT:
Wait, no. It compiles fine. Sorry.

[Edited by - snooty on October 18, 2006 5:24:29 AM]

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!