Re: Microsoft & GNU compiler 2 :)

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jason Winnebeck (gillius_at_mail.rit.nspam.edu)
Date: 07/19/04


Date: Mon, 19 Jul 2004 08:13:53 -0400

Simon Trew wrote:
> "Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@mvps.org.nospam>
> wrote in message news:eSsTPUaaEHA.3692@TK2MSFTNGP09.phx.gbl...
>
>><quote>
>>I no longer consider this
>>argument conclusive (if I ever did), but the decision has proven useful in
>>that it allows programmers to add and remove public and private
>>specifications during debugging without quietly changing the meaning of
>>programs.
>>
>></quote>
>
>
> But it doesn't. If you add a private variable to the base class (X) then the
> derived class (XX) suddenly can't see the global variable.
>
>

I think what Carl meant was if you make a public variable private, the
derived class won't silently use the global variable by the same name.
Meaning there is a compiler error, instead of it "quietly changing the
meaning" of the program to use the global. What I take from that is to
say that getting the compiler error and seeing that you forgot to
change/remove the reference is better than it compiling and accessing a
variable one did not intend.

Jason



Relevant Pages

  • Re: "this" and "base"
    ... compiler and the programming language. ... a private inherited field in a base class from a derived class is that the ... > because the member "is a private". ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: changing access modifier of base method
    ... I'm not sure if this counts as a different meaning than your ... quality in the Java resources I've seen:)). ... design reason for making sealed the default. ... many more private members than public. ...
    (microsoft.public.dotnet.languages.csharp)
  • "this" and "base"
    ... Why can't you access a private inherited field from a base ... because the member "is a private". ... class manually in the derived class as shown in figure 1: ... because I inherit a member with the exact same signature ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Events with accessors
    ... Personally, I wouldn't - I'd create a protected method called OnMyEventwhich raises the event, and keep the detail private. ... The corresponding handler, the corresponding delegate, the corresponding event arguments--and now, yet another entity so that I can define an Event in an abstract base class for each derived class to raise when appropriate. ... I really don't see why events declared in the usual way couldn't have been set up for raising by derived classes, despite their encapsulation of the private delegate. ... A derived class can use the event in exactly the same way as a different class can - but it can't get at the private implementation, just as a public or protected property prevents you from getting at the implementation. ...
    (microsoft.public.dotnet.general)
  • Re: classes: virtual functions from baseclass
    ... > int something; ... > the function once again inside the derived class? ... the private: access specifier. ...
    (comp.lang.cpp)