Private visible?

Walter Bright newshound at digitalmars.com
Fri Jul 14 11:01:02 PDT 2006


Lucas Goss wrote:
> Walter Bright wrote:
>>
>> Sometimes it is valuable to be able to say "you can't do this 
>> operation with this type". I don't see why this ability should be 
>> restricted to C++.
> 
> Can someone come up with an example or explain why this would be 
> valuable? To make sure we're on the same page, we're talking about:
> 
> ----
> class Base {
>   public:
>     virtual int Number() = 0;
> };
> ...
> class Child : public Base {
>   private:
>     int Number() { return 1; }
> };

I think it's a bug that the compiler allows this. It should be illegal 
code, because it breaks encapsulation.



More information about the Digitalmars-d mailing list