Xref: news-dnh.mv.net comp.os.msdos.djgpp:2914 Path: news-dnh.mv.net!mv!news.sprintlink.net!bga.com!news2.realtime.net!news-out.internetmci.com!newsfeed.internetmci.com!in1.uu.net!genmagic!goonsquad.spies.com!uuwest!alcyone!max From: max AT alcyone DOT darkside DOT com (Erik Max Francis) Newsgroups: comp.os.msdos.djgpp Subject: Re: Templates in DJGPP. Date: Fri, 27 Oct 95 18:11:35 PST References: <1995Oct27 DOT 092027 AT zipi DOT fi DOT upm DOT es> Organization: &tSftDotIotE Lines: 43 To: djgpp AT sun DOT soe DOT clarkson DOT edu Dj-Gateway: from newsgroup comp.os.msdos.djgpp a920101 AT zipi DOT fi DOT upm DOT es writes: > How do I use them in GCC??? I've searched in the docs and so, but can't find > anything. Help? The information you need _is_ in the info files; it's just not straightforward or easy to find. (I plagued this group a while ago with questions about templates myself.) What you basically have to do is 1. define the template class, 2. instantiate it in a certain module for your particular application, and 3. include that module in with the rest of your modules for linkage. Search around in the gcc documentation for templates; you should find the information you need. Basically, what you do is make whatever typedefs you feel are appropriate, and then instantiate the template with a syntax which looks like a prototype definition (using templates) for everything you need. First you do something like template class LIST; that instantiates the class itself and its member functions. For out- of-line member functions, say, an operator << function for writing a LIST to an iostream, you use a template instantiation something like the following: template ostream &operator <<(ostream &o, const LIST list); This should do the trick. I use this on a regular basis and have never seen any troubles. I've found that with gcc if you try the other route, which is to _use_ the template classes in this manner (even if you do it in a way which is never used), the instantiations seem to be optimized out. The above description is the way to go. Erik Max Francis, &tSftDotIotE || uuwest!alcyone!max, max AT alcyone DOT darkside DOT com San Jose, California, U.S.A. || 37 20 07 N 121 53 38 W || the 4th R is respect H.3`S,3,P,3$S,#$Q,C`Q,3,P,3$S,#$Q,3`Q,3,P,C$Q,#(Q.#`-"C`- || 1love || folasade _Omnia quia sunt, lumina sunt._ || GIGO Omega Psi || http://www.spies.com/max/ "Hands that once picked cotton can now pick Presidents." -- Jesse Jackson