🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Nathan Sidwell Tue, 27 Feb 1996 18:54
Base class access specifiers
#3527
Author: Nathan Sidwell
Date: Tue, 27 Feb 1996 18:54
58 lines
2373 bytes
I'm having problems determining if the following is legal or not,
-snip
class A {
protected:
  int member;
  void func(A){};
};
  
class B : protected A {
  void func(B arg) {   
    A::func(A(arg));      // ok
  };
};
  
class C : protected B {
  void func(C arg) {   
    A::func(A(arg));      // failed
  };
};  
-snip

I think that the line marked 'failed' is the same as the line marked 'ok'.

However g++ 2.7.2 reports
foo.cc: In method `void C::func(class C)':
foo.cc:15: fields of `const A' are inaccessible in `C' due to private
								inheritance
foo.cc:5: in passing argument 1 of `A::A(const A &)'
foo.cc:15: in conversion to type `A'

and cfront says,
"foo.cc", line 15: error: cast: C* -> base A*; protected base class
"foo.cc", line 15: error:  object or pointer missing for A::func() of type
								void A::(A)

SGI CC accepts the code.

As far as I can see section 11.2 of the draft standard can be applied
recursively to determine the access to A's members in C. This would make
the two lines have the same meaning.

Where am I going wrong, or are g++ and cfront confused?

nathan

--
Nathan Sidwell                         Holder of the Xmris home page
Chameleon Architecture Group at SGS-Thomson, formerly Inmos
http://www.pact.srf.ac.uk/~nathan/                  Tel 0117 9707182
nathan@inmos.co.uk or nathan@bristol.st.com or nathan@pact.srf.ac.uk


[ comp.std.c++ is moderated.  To submit articles: Try just posting with your
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads