|
|
Orchid XP v7 wrote:
> Darren New wrote:
>> Invisible wrote:
>>> (and AFAIK in plain C) you *must* expose all implementation details
>>> of a type in order for anybody else to be able to touch it.
>>
>> Nah. Just use a forward-declared struct and pass pointers to it. You
>> know, like fopen/fread/fwrite/fclose. Note those haven't changed
>> since the first edition of K&R.
>
> I have no concept of what you're talking about - but you're probably
> right...
In C, you declare a pointer to a structure without defining the layout
of the structure. C allows this, because it assumes all pointers are the
same size and have a unified alignment requirement and can all live in
the same kinds of registers and things like that.
Then in your code file, you define the structure. Creating an object
involves allocating the structure and returning the opaque pointer to
it. Using the object requires passing the opaque pointer back in.
No implementation details are visible at all.
http://en.wikipedia.org/wiki/C_file_input/output
--
Darren New / San Diego, CA, USA (PST)
Remember the good old days, when we
used to complain about cryptography
being export-restricted?
Post a reply to this message
|
|