Incomplete types question
NoUseForAName via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jul 7 21:44:36 PDT 2014
In C my favorite way of achieving encapsulation is to use
incomplete types. The module header contains the definition of an
incomplete type and the prototypes for the public functions which
operate on it. I have read D has incomplete types too however D
does not have headers and as a C guy I do not know how to
implement this scheme without a .h/.c separation.
As I said, in C I put the incomplete declaration in the header
while keeping the complete declaration private to the module. How
do I do this in D? I mean type is complete within the module
itself (and thus can be instantiated there) but incomplete for
clients (i.e. other modules) i.e. instantiating or modifying data
of that type directly is impossible.
P.S.: It seems D lingo for incomplete types is "opaque types".
More information about the Digitalmars-d-learn
mailing list