【发布时间】:2013-10-31 23:52:17
【问题描述】:
假设我有这些课程:
class Base
{
public:
class Foo { ... };
...
};
然后从基类派生另一个类:
class Derived : public Base
{
// no mention or redefinition of nested class "Foo" anywhere in "Derived"
};
这是否意味着我们现在有一个不同的Derived::Foo,或者Derived::Foo 与Base::Foo 完全相同?
这里有一个转折点:如果有人抛出Derived::Foo 的实例怎么办?在这种情况下会不会被抓住:
catch ( const Base::Foo &ex )
{
// would this also catch an instance of Derived::Foo?
}
【问题讨论】:
标签: c++ inheritance try-catch nested-class