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]

multiple template classes in a single file


I'm trying to port code from Visual C++ (6)to gcc (gcc version 2.95.4
20010319) and the following code snippet fails to compile with gcc.  I'm
declaring two template classes in a single .cpp file and it produces the
following error:

test.cpp:40: parse error before `&'
test.cpp:40: missing ';' before right brace
test.cpp:41: parse error at null character

Compiling the file test.cpp:

namespace NS
{
   template <class X> class Object_ptr
   {
   public:
      typedef X element_type;

      explicit Object_ptr(void) throw() : m_itsPtr(0)
      {
      }

      ~Object_ptr()
      {
      }


   private:
      X                                      * m_itsPtr;

      Object_ptr(const Object_ptr&) {}
   };


   template <class X> class Object
   {
   public:
      typedef X element_type;

      explicit Object(char * name) throw() : m_itsPtr(0)
      {
      }
      ~Object()                   {delete   m_itsPtr;}

   private:
      X                       * m_itsPtr;

      Object(const Object_ptr&) {}
   };
}

What am I missing?  Pleace CC me on replies since I'm not subscribed to this
list.

Thanks,
brian


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