Private visible?
xs0
xs0 at xs0.com
Fri Jul 14 07:05:37 PDT 2006
>> Private members should be totally invisible, because that's the point of
>> marking them private.
>
> But then the compiler loses the ability to make intelligent error
> messages, right?
No, the compiler obviously still sees them.. But as far as things like
overload resolution are concerned, the end result should be the same as
if they didn't exist (note that this point is moot if they're all
required to be at the same visibility)
>> As for overloading issues, as far as I am concerned, feel free to
>> require all methods with the same name to have the same protection;
>> anything else is poor taste anyway.
>
> Really? Then how do you hide the previous method implementation?
I'm not sure what you're asking here.. You can override methods as
normal. You can also increase visibility, if you want, but once you do
it for one method named "foo", you have to do it for all other methods
named "foo" as well.
> class A {
> protected pm() { ... }
> }
> class B : A {
> // ugly, isn't it :(
> protected pm() { assert(0); /* subclasses: do not use this */ }
> public pm2() { super.pm(); ... }
> }
ugly indeed, but not necessary :)
> class A {
> protected pm() { ... }
> }
> class B : A {
> public pm() { super.pm(); ... }
> }
All methods in class B called "pm" have the same visibility, so no
problem...
xs0
More information about the Digitalmars-d
mailing list