delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/28/20:24:09

From: "John Bodfish" <bodfish AT als DOT ameritech DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: templates in DJGPP
Date: 28 Aug 1997 14:11:06 GMT
Organization: Ameritech Library Services
Lines: 45
Message-ID: <01bcb3bb$95126c00$dfcde7c0@JOHNB.als.ameritech.com>
References: <3400DF67 DOT 3545 AT student DOT uq DOT edu DOT au>
NNTP-Posting-Host: n5223.als.ameritech.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

gyroscope <s336627 AT student DOT uq DOT edu DOT au> wrote in article
<3400DF67 DOT 3545 AT student DOT uq DOT edu DOT au>...
> I am wondering what *exactly* is the syntax for implementing templates in
DJGPP.

Your example compiles for me. What's your version of gcc?
When I run "gcc -v" I get "gcc version 2.7.2".

To be real sure your code was working, I added some usage
of the stack class:

#include <ostream.h>

template<class T>
class stack {
public:
        T* v;
//      etc.
};

int main(void)
{
        int One = 1;
        stack<int> IntStack;

        float Half = 0.5;
        stack<float> FloatStack;

        IntStack.v = &One;
        FloatStack.v = &Half;

        cout << "One is " << *IntStack.v << endl;
        cout << "Half is " << *FloatStack.v << endl;

        return 0;
}

I compiled this with "gcc -o templates templates.cc -lstdcx" and got
no errors.


-- 
John Bodfish
bodfish AT als DOT ameritech DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019