Re: basic question on C++

From: Leor Zolman (leor_at_bdsoft.com)
Date: 02/05/04


Date: Thu, 05 Feb 2004 02:28:08 GMT

On Wed, 04 Feb 2004 17:21:50 -0800, Digital Puer
<digital_puer@hotjail.comet> wrote:

>On a job interview question, this was asked:
>
> From the point of view of a derived class, how do you set
>variables in the base class to be all private? Give
>an example using class A (base) and B (derived).
>
>Any ideas? I can't clarify because that's all that was given.
>

All I can think of is that "how do you set variables in the base class
to be all private" is meant as if it were followed with "...to the
derived class" (since the sentence begins, "From the point of view of
a derived class"). So another way of asking this would be, "How can a
derived class make sure that all the accessible variables it inherits
from its base class are not accessible to its further derived
classes". That would be via private inheritance:
        class B : private A {
                ...
        };
-leor

Leor Zolman
BD Software
leor@bdsoft.com
www.bdsoft.com -- On-Site Training in C/C++, Java, Perl & Unix
C++ users: Download BD Software's free STL Error Message
           Decryptor at www.bdsoft.com/tools/stlfilt.html



Relevant Pages

  • Re: Sharing an instance of an object across classes
    ... I was thinking when you instantiate a derived class, ... base class instance in memory, so you could call the base class's functions ... Class clsData ... Private Shared _instance As New clsData ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Sharing an instance of an object across classes
    ... I was thinking when you instantiate a derived class, ... base class instance in memory, so you could call the base class's functions ... Class clsData ... Private Shared _instance As New clsData ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Application.Run() problem
    ... still am very much confused about the paint event handler. ... It most obviously should be the derived class, ... It seems that you're not understanding how inheritance works. ... which ensures that the base class uses the same ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Very Confused on Page 33
    ... On page 33 Bruce is explaining inheritance. ... > base class you can also send to objects of the derived class. ... The programmatic difference enables the subclass ...
    (comp.lang.java.help)
  • Re: attribute or subclass
    ... With inheritance the derived class code ... reference in place of the base class reference. ...
    (comp.object)