new principle of division between structures and classes
Weed
resume755 at mail.ru
Tue Jan 6 11:22:44 PST 2009
(Here I generalise my sentence with supplement)
The POD data and the data supporting polymorphism are necessary to us.
POD the data is stored in structs and polymorphic objects is classes.
Both types (class and struct) can be instanced in a heap or on a stack.
(And in invariant ROM too, but there it is not important)
Classes and structures support inheritance. But structures do not
support polymorphism (as are POD type without vptr) - at attempt to
implement virtual function in structure the compiler will give out an
error: "struct StructName is POD type, it is not support polymorphism,
use class instead of". (And certainly structures are not inherited from
classes, including from super class Object)
Thus, the programmer always knows the object is POD-data or not. The
problem of simple alteration of structure to a class and vice versa when
necessary also solved.
For an exception of splitting of objects it is necessary to check during
compilation: or to forbid assignment on value for types not being to the
data (how now it works for the structs objects on value) or to forbid
the access to the fields added at descending inheritance (its more
difficult but desirable)
Please, state critical remarks
More information about the Digitalmars-d
mailing list