Is there a reason to differentiate between static and non-static data members in terms of prohibition of the usage of abstract types?

  abstract-data-type, c++, language-lawyer

In class.abstract we can see in the Note 3 that:

An abstract class can be used only as a base class of some other class; no objects of an abstract class can be created except as subobjects of a class derived from it ([basic.def], [class.mem]).

This rules out the usage of abstract classes as subobjects and it makes sense to me (though this is just a note, which is non-normative, IIRC).

However, in class.mem we can read that:

The type of a non-static data member shall not be an incomplete type ([basic.types]), an abstract class type ([class.abstract]), or a (possibly multi-dimensional) array thereof.
[Note 5: In particular, a class C cannot contain a non-static member of class C, but it can contain a pointer or reference to an object of class C. — end note]

(emphasis mine)

What seems strange to me is the specific wording: "non-static". Why is it explicitly stated that this refers to non-static members? I don’t believe we’re allowed to have static declarations or definitions of objects of abstract types. Does the standard actually allow static data members to be abstract and no sane compiler implements that? Or it does prohibit such uses (in that case why the distinction in static vs non-static data in the aforementioned paragraph)?

Source: Windows Questions C++

LEAVE A COMMENT