Re: inhibit compiler warning C4624 for a class hierarchy
Ben Voigt <rbv@nospam.nospam> wrote:
It appears that none of your classes are actually POD types.
Luckily, you don't need to meet a higher bar of using only POD
types: it should be sufficient for your purposes to have types with
trivial constructor and destructor. In particular, you can use
inheritance, but you shouldn't have any user-declared constructors
or destructors.
... as well all non-static data members should have trivial
constructors and destructors, which is why today I wrote "the
hierarchy will permit only POD members"... which seems to be an
essential part of the lower bar you speak of.
<nitpick>
You seem to be using the term POD as a shortcut for "a fundamental type,
or a class with trivial constructor and destructor". Any POD struct has
trivial constructor and destructor, but not every one with trivial
constructor and destructor is POD.
For a structure to have a trivial constructor, it is necessary that all
its members also have a trivial constructor. They don't have to be PODs
(e.g. they could be classes derived from other classes, or have private
members). E.g.
struct A { int x; }; // POD
struct B : public A { int y; }; // not a POD
struct C { A a; B b; }; // not a POD
A, B and C all have trivial constructors and destructors. Only A is a
POD-struct. For all three it is legal to do something like
C* pc = (C*)malloc(sizeof(C));
// do something to pc
free(pc);
</nitpick>
What's also needed is a noinherit keyword for class members that
affects name visibility, especially overload resolution, but not
access:
struct X
{
noinherit static int x;
static int y;
noinherit enum { xxx = 1; }
noinherit int f(int);
};
struct Y : public X
{
void f(double);
void test() {
x; // not allowed
X::x; // ok
I'm not sure how this is useful.
xxx; // not allowed
__super::xxx; // ok
What would '__super' mean in the presense of multiple inheritance? In
any case, I still don't see how this construct is useful.
f(1); // calls Y::f(double)
So it does now, without any new keyword.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925