为什么C ++ 11允许抽象的最终类?

时间:2014-02-16 02:04:01

标签: c++ c++11

为什么以下代码会编译?我正在使用Visual Studio;我不确定它是否符合标准,或者是否有充分的理由允许这样做,或者它只是对语言的疏忽。

struct Base {
  virtual void foo() = 0;
};

// since this class is final and abstract, it can never be
// instantiated - why isn't its very declaration an error?
struct Derived final : Base {};

int main() {
  //Derived derived; // this IS an error, but relies on someone trying
                     // to instantiate the class, and the error is at the site
                     // of instantiation, not the class itself
}

0 个答案:

没有答案