🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Dirk Herrmann Wed, 08 Nov 1995 11:33
Re: Q: nested classes in templates?
#2453
Author: Dirk Herrmann
Date: Wed, 08 Nov 1995 11:33
53 lines
1492 bytes
Hello!

I'm looking for some help with the c++ syntax.
What I want to do is the following: I have a template
class X<T>. Within X I want to declare a nested class N.

My approach is the following:



template<class T>
class X
{
    class N;   // Declaration here, definition follows
	       // below. As far as I know, this is/will
	       // be allowed with std-C++. (r.9.7)
    N* np;     // Question 1: This should be legal, but
    N  n;      // this might not.
};


template<class T>
class X<T>::N  // Question 2: Is this syntax correct?
{
    void N();
    T  t;
};


template<class T>
void X<T>::N::N()  // Solution 1: IMO this makes sense.
    : t()
{
}


template<class T>
void X<T>::N<T>::N()  // Solution 2: Could have to be this way
	              // as well, but solution 1 looks nicer.
    : t()
{
}

Thank you in advance for your answers.

Dirk Herrmann


---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
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