delorie.com/archives/browse.cgi | search |
From: | ryot AT bigfoot DOT com (George Ryot) |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: More template problems (C++) |
Message-ID: | <380b1a61.7181287@news.clara.net> |
References: | <7tp5ti$sp0$2 AT vixen DOT cso DOT uiuc DOT edu> |
X-Newsreader: | Forte Agent 1.5/32.452 |
X-No-Archive: | yes |
MIME-Version: | 1.0 |
Lines: | 48 |
Date: | Sun, 17 Oct 1999 00:50:09 GMT |
NNTP-Posting-Host: | 195.8.92.99 |
X-Complaints-To: | abuse AT clara DOT net |
X-Trace: | nnrp4.clara.net 940121409 195.8.92.99 (Sun, 17 Oct 1999 01:50:09 BST) |
NNTP-Posting-Date: | Sun, 17 Oct 1999 01:50:09 BST |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
"Al Combs" <acombs AT uiuc DOT edu> wrote: > Ok, I know I've been here before with template problems, and now I need > specific help again to understand how templates work in DJGPP (G++). Here is I already answered this, what was not clear from my previous post? For your example code there is nothing special about how g++ handles templates. Some other compilers can handle templates in the way you want but they do so in a non-standard way. G++ conforms to ANSI/ISO standard (mostly) so will not compile your code. > Now, my question is what SPECIFICALLY would I need to change to make gpp > compile it properly? In otherwords, how would I have to re-write the code to > make it work? Please be as speciffic as possible. You need *TWO* files only: foo.h & main.cpp // foo.h template<class Etype> class Foo { public: void Replace(); }; // ALSO IN foo.h <----- *** THIS IS WHAT YOU ARE MISSING *** template<class Etype> void Foo<Etype>::Replace() {} // main.cpp #include "foo.h" int main() { Foo<int> hi; hi.Replace(); } And compile with: gpp -Wall -W main.cpp -o main -- george
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |