Using closure in function scope to make "real" private class members
Dom Disc
dominikus at scherkl.de
Sun Jun 5 20:42:59 UTC 2022
On Sunday, 5 June 2022 at 19:48:03 UTC, Ola Fosheim Grøstad wrote:
> On Sunday, 5 June 2022 at 19:41:36 UTC, Dom Disc wrote:
>> Anybody can declare friends, without even touching the file
>> where the class is defined, and thereby access things that
>> shouldn't even be visible to them (implementation details or
>> even security relevant things)!
>
> No, I don't think so:
>
> «If a program contains more than one definition of a type, then
> each definition must be equivalent.»
?!?
You don't need to re-declare the class. You can simply overwrite
a friend function. Ok, if the class don't have any friends, this
doesn't work. But most of the time there are some...
More information about the Digitalmars-d
mailing list