Topic: Access to classes


Author: "Kit Smithers" <kit.smithers@ats.uk.eds.com>
Date: 1999/11/05
Raw View
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?
};

class Unrelated
{
  public:
    TimeDelta operator-(const SystemTime& sys_time);
};


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);
      ^

What I cannot tell from the standard (I presume section 11 is the right
place to be looking) is which is the correct compiler? I don't see why I
shouldn't be allowed to return an instance of a class which a base class has
privately derived from yet an unrelated class can do so without any problem.

--
Kit Smithers




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