This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ Language Lawyer Question



Hi,


I was surprised that a particular piece of code compiled
(with gcc 2.96 and 3.2.3 on RedHat 7.3) and wanted a
language lawyer to tell me if this code should have.
The issue is that I accidentally made a type definition
private when it was used as an argument to a public method.

namespace N {
  class C {
    private:
      typedef int T1_t;
    protected:
      typedef int T2_t;
    public:
      C();
      ~C();
      int f1(T1_t);  // private type used for public method
      int f2(T2_t);  // protected type used for public method
  };
}

N::C::C() { ; }
N::C::~C() { ; }
int N::C::f1(T1_t x) { return x+1; }
int N::C::f2(T2_t x) { return x+2; }

Should this work?  If so, what is the rationale for allowing it.
If not, is this a known issue with G++?

Thanks.

--joel sherrill



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]