import concerns (was Re: Historical language survey)
Sean Kelly
sean at f4.ca
Sat Jul 8 08:54:33 PDT 2006
Sean Kelly wrote:
> Walter Bright wrote:
>> Ivan Senji wrote:
>>> How does this sound in the documentation:
>>> "A module level function that is declared private can not be used in
>>> another module unless there is another public function with the same
>>> name."
>>> <- This is just crazy(or does it justsound crazy to me), IMO private
>>> "void foo(long x);" in the above example should not be included in the
>>> overload resolution.
>>
>> Consider the following C++ code:
>>
>> struct S
>> {
>> public void foo(long);
>> private void foo(int);
>> };
>> struct T
>> {
>> public void foo(long);
>> };
>>
>> ...
>>
>> S s;
>> s.foo(1); // error, foo(int) is private
>> T t;
>> t.foo(1); // ok
>>
>> Note that it sees S::foo(int) and it participates in overload
>> resolution even though it is private. In other words, accessibility is
>> checked after lookup and after overload resolution.
>
> I'm not sure this is an entirely valid example because private member
> functions in D are not inherited
I misspoke--they're not inherited in C++ either. However, they can be
overridden in C++ but not in D. This is the pertinent distinction IMO.
Sean
More information about the Digitalmars-d
mailing list