www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/06/10/05:45:14

From: "Tomas Nilsson" <tnidt97 AT student DOT vxu DOT se>
Newsgroups: comp.os.msdos.djgpp
Subject: template problem in djgpp
Date: Sun, 10 Jun 2001 11:44:18 +0200
Organization: Lund Institute of Technology, Sweden
Lines: 40
Message-ID: <9fvfgf$obj$1@news.lth.se>
NNTP-Posting-Host: tnidt97.idet.vxu.se
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2014.211
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hello,
I have a problem with templates i djgpp 2.03. I have tried the following
program:

file class1.h:
template<class TYPE>
class class1 {
private:
        TYPE T;
public:
        void f1();
};

file class1.cpp:
#include"class1.h"
template <class TYPE> void class1<TYPE>::f1() {}

file main.cpp
#include"class1.h"
int main() {
        class1<int> c1;
        c1.f1();
}

The program compiles without errors and warnings, but then something goes
wrong in the
linking process. The linker ld in djgpp returns the error message "undefined
reference to class<int>::f1(void)". This is very strange, because the UNIX
compiler CC can compile and build this program without any problem, and CC
one of the best approximation of the C++ standard I know.
    Can anyone see what could be causing this problem and why it works in CC
and not djgpp? I would be very grateful for any help with this problem!

Thanks in advance,
Tomas Nilsson





- Raw text -


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