Topic: Declaring non-inline subclass functions


Author: jason@cygnus.com (Jason Merrill)
Date: Wed, 18 May 1994 07:31:25 GMT
Raw View
>>>>> Reinhard Schiedermeier <Reinhard.Schiedermeier@deejai.mch.sni.de> writes:

> : I thought the following would be the *standard* but it doesn't compile
> : under Borland C++ 4.0 (it says that cNamedItem must be a class or struct)

> : template <class T>
> : cNamedList<T>::cNamedItem::cNamedItem(string &name, T &data):

> I have tried the same with GNU-C++ 2.5.8 -- without success.
> The definition has to go inline.

This is a bug in both compilers.  I plan to fix it in g++ for the 2.7
release cycle.

Jason




Author: Reinhard.Schiedermeier@deejai.mch.sni.de (Reinhard Schiedermeier)
Date: 17 May 1994 12:53:46 GMT
Raw View
Gordon Tyler (gordo@nynexst.com) wrote:

: I'm looking for the rule for declaring a subclass function, it should be:

: int superClass::subClass::function(param1, param2)

: but...

: Consider the following class template:

: template <class T>
: class cNamedList {
:    struct cNamedItem {
:       string _name;
:       T _data;
:       cNamedItem *_next;
:       cNamedItem(string &name, T &data): _name(name), _data(data), _next(0) {}
:       ~cNamedItem() { delete _next; }
:    };
:    cNamedItem *_first;
:    cNamedItem *_prev;
: public:
:    cNamedList(): _first(0), _prev(0) {}
:    ~cNamedList() { delete _first; }
:    void add(string, T);
:    T *lookup(string);
: };

: How do I take the cNamedItem constructor out-line?
: I thought the following would be the *standard* but it doesn't compile
: under Borland C++ 4.0 (it says that cNamedItem must be a class or struct)

: template <class T>
: cNamedList<T>::cNamedItem::cNamedItem(string &name, T &data):
:   _next(0), _name(name), _data(data)
: {
: }

: Does this work on anybody else's compiler?
: Is it possible? Is there a scope problem?

: Thanks,
: --Gordie.

: --------------------------------------------------------
:  Gordon Tyler                NYNEX Science & Technology
:  gordo@nynexst.com           Craft Access Lab
: --------------------------------------------------------
:      "That's not a bug, it's just a hidden feature"

I have tried the same with GNU-C++ 2.5.8 -- without success.
The definition has to go inline.

--Schiedi




Author: Gordon Tyler <gordo@nynexst.com>
Date: Wed, 11 May 94 15:34:59 PDT
Raw View
I'm looking for the rule for declaring a subclass function, it should be:

int superClass::subClass::function(param1, param2)

but...

Consider the following class template:

template <class T>
class cNamedList {
   struct cNamedItem {
      string _name;
      T _data;
      cNamedItem *_next;
      cNamedItem(string &name, T &data): _name(name), _data(data), _next(0) {}
      ~cNamedItem() { delete _next; }
   };
   cNamedItem *_first;
   cNamedItem *_prev;
public:
   cNamedList(): _first(0), _prev(0) {}
   ~cNamedList() { delete _first; }
   void add(string, T);
   T *lookup(string);
};

How do I take the cNamedItem constructor out-line?
I thought the following would be the *standard* but it doesn't compile
under Borland C++ 4.0 (it says that cNamedItem must be a class or struct)

template <class T>
cNamedList<T>::cNamedItem::cNamedItem(string &name, T &data):
  _next(0), _name(name), _data(data)
{
}

Does this work on anybody else's compiler?
Is it possible? Is there a scope problem?

Thanks,
--Gordie.

--------------------------------------------------------
 Gordon Tyler                NYNEX Science & Technology
 gordo@nynexst.com           Craft Access Lab
--------------------------------------------------------
     "That's not a bug, it's just a hidden feature"