Topic: protected access


Author: "Michael Kochetkov" <mkochetk@elvis.ruuuu>
Date: 1999/06/15
Raw View
>  class A
>  {
>   protected:
>       void dothis( void );
>   };
>
>  class B : public class A
It will not compile. You can not write ": public class".

>  {
>   private:
>       void  do( void ) {
It will not compile. "do" is a reserved word.

>            dothis();  // ok -> protected access
Ok, your obect calls protected member function of it's own.

>            a->dothis() ; // sun compiler says NO, (other compilers say
it's ok
Nope, your obect calls protected member function of some other object. By
the way, what "other" compilers do you mean?

>        };
>   A *  a;
>  }
And ';' as a matter of course.

>  So, the question is should 'B'be able to call a->dothis() since it's a
> subclass of 'A'?
No, it should not.

Regards,
Michael Kochetkov.
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]