Thread View: comp.std.c++
2 messages
2 total messages
Started by Marc Girod
Thu, 23 Nov 1995 15:32
Dependency through template use
Author: Marc Girod
Date: Thu, 23 Nov 1995 15:32
Date: Thu, 23 Nov 1995 15:32
39 lines
2028 bytes
2028 bytes
Hello!
I compile the following example:
--------------------------------
template <class T> class X {
T t_;
};
class Y;
class Z {
X<Y>* x_;
};
--------------------------------
and get an error from my compiler:
CC: "foo.C", line 2: error: Y undefined, size not known (1437)
"foo.C", line 2: error detected during the instantiation of X <Y>
"foo.C", line 8: is the site of the instantiation
Could you confirm that my compiler is wrong, and should not require
that I #include the definition of type Y.
I could not find the answer in the draft (I looked in chapter
14.2...).
Thanks!
--
+---------------------------------------------------------------------------+
| Marc Girod - Nokia Telecommunications Phone: +358-0-511 27703 |
| Kilo RD 4 - P.O. Box 12 Fax: +358-0-511 27432 |
| SF-02611 Espoo 61 - Finland Internet: marc.girod@ntc.nokia.com |
| X.400: C=FI, A=Elisa, P=Nokia Telecom, SUR=Girod, GIV=Marc |
+---------------------------------------------------------------------------+
[ 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. ]
Re: Dependency through template use
Author: David Vandevoorde
Date: Fri, 24 Nov 1995 17:24
Date: Fri, 24 Nov 1995 17:24
26 lines
1277 bytes
1277 bytes
>>>>> "MG" == Marc Girod <girod@dshp01.trs.ntc.nokia.com> writes:
[...]
MG> template <class T> class X {
MG> T t_;
MG> };
MG> class Y;
MG> class Z {
MG> X<Y>* x_;
MG> };
[...]
I'm pretty sure it's correct C++ under the current DWP
(and my compiler compiles it quietly). If it is a serious
problem, does a typedef help?
class Z {
typedef X<Y>* Ptr_;
Ptr_ x_;
};
Daveed
[ 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