Topic: Problem with injection of class name with private base classes (Was: Access to classes)


Author: Valentin Bonnard <Bonnard.V@wanadoo.fr>
Date: 1999/11/05
Raw View
Kit Smithers wrote:

> I have the a question about this section of code:
>
> class TimeDelta
> {
> };
>
> class Time : private TimeDelta
> {
> };
>
> class SystemTime : public Time
> {
>   public:
>     TimeDelta operator-(const SystemTime& sys_time); // error?
> };

> If I use g++ it compiles without any problem but if I use KCC (Kuck and
> Associates C++ compiler) then it fails with the error
>
> "acces.cxx", line 13: error: type "TimeDelta::TimeDelta" is inaccessible
>       TimeDelta operator-(const SystemTime& sys_time);
>       ^

The error message says it all: you are trying to access
TimeDelta::TimeDelta
(actually SystemTime::TimeDelta), which obviously isn't accessible.)

Use ::TimeDelta instead.

> What I cannot tell from the standard (I presume section 11 is the right
> place to be looking)

The right place is actually 9/1. KCC is correct.

--

Valentin Bonnard


[ 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              ]