Incomplete types question

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 8 05:08:05 PDT 2014


On Tuesday, 8 July 2014 at 11:55:01 UTC, bearophile wrote:
> NoUseForAName:
>
>> Thanks, that is what I was looking for.
>
> Why do you need a public pointer type but private struct type?

As the OP wrote:
> In C my favorite way of achieving encapsulation is to use 
> incomplete types.

(Also known as PIMPL.)

In C, it's the only type-safe way to get encapsulation, AFAIK. In 
languages with access protection, it's probably not as useful, 
but I'm sure it has its applications...


More information about the Digitalmars-d-learn mailing list