This is the mail archive of the gcc-help@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]

Nested protected class within namespace


Hello,

I have the following code:

----------
namespace NameSpace {
class Outer {
public:
  class Inner {};
  friend Inner * convertInner(int i);
protected:
  class InnerSetup : public Inner {};
};
}

NameSpace::Outer::Inner * NameSpace::convertInner(int i) {
  if (i == 0) return new NameSpace::Outer::Inner();
  else        return new NameSpace::Outer::InnerSetup();
}
----------

It compiles fine with g++ version 4.0.1, but newer versions (4.2.1 and 4.4.0) give me the following error:

example.cpp:11: error: 'NameSpace::Outer::Inner* NameSpace::convertInner(int)' should have been declared inside 'NameSpace'

It looks to me like the function IS declared inside 'NameSpace', so I can't tell what the compiler is trying to tell me.

** Bill Spotz                                              **
** Sandia National Laboratories  Voice: (505)845-0170      **
** P.O. Box 5800                 Fax:   (505)284-0154      **
** Albuquerque, NM 87185-0370    Email: wfspotz@sandia.gov **







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