Article View: comp.std.c++
Article #2453Re: Q: nested classes in templates?
From: Dirk Herrmann
Date: Wed, 08 Nov 1995 11:33
Date: Wed, 08 Nov 1995 11:33
53 lines
1492 bytes
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. ]
Technical Details
Message-ID:
<Pine.SUN.3.91.951108104042.6427B-100000@sallust>Path:
arc1-ca.pugleaf.net!tcsi.tcs.com!agate!agate!MattShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!tcsi.tcs.com!agate!agate!Matt From: Dirk Herrmann <Herrmann@ida.ing.tu-bs.de> Newsgroups: comp.std.c++ Subject: Re: Q: nested classes in templates? Date: 08 Nov 1995 11:33:20 GMT Organization: <none> Approved: Matt@Austern Message-ID: <Pine.SUN.3.91.951108104042.6427B-100000@sallust> NNTP-Posting-Host: austern.hip.berkeley.edu