由买买提看人间百态

topics

全部话题 - 话题: vbase
(共0页)
i**p
发帖数: 902
1
#include
using namespace std;
class Base {
public:
void f() const {}
};
class vBase {
public:
virtual void f() const {}
~vBase() {}
};
main() {
Base b;
//! const Base cb; // To enable it, add Base() {} to the class
const vBase vb;
const vBase vcb;
}
p***o
发帖数: 1252
2
Your compiler is buggy. Neither VC nor gcc requires a ctor in Base.
l*********s
发帖数: 5409
3
the standard requires custom ctor for const class, probably thee compiler
has a bug to let you go through with vCB
quote/
8.5]
9. If no initializer is specified for an object, and the object is of
(possibly cv-qualified) non-POD class type (or array thereof), the object
shall be default-initialized; if the object is of const-qualified type,
the underlying class type shall have a user-declared default constructor.
Otherwise, if no initializer is specified for an object, the object and
its subobje... 阅读全帖
(共0页)