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
}
inherited enum
Why does the following work? Aren't A::F and B::F different types?
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.
Thank you.
But with the following, the compiler complains:
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]
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]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement