import concerns (was Re: Historical language survey)

Walter Bright newshound at digitalmars.com
Sat Jul 8 01:26:46 PDT 2006


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.



More information about the Digitalmars-d mailing list