delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/17/14:59:09

Message-ID: <350EBB24.EAEB38D5@geocities.com>
Date: Tue, 17 Mar 1998 12:04:20 -0600
From: Sahab Yazdani <sahaby AT geocities DOT com>
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Templates AND GCC

I am making a set of easy to use templates, and linking them into a file
called USEFUL.A,  then when i go to compile these with a program TEST.CC
the compiler gives me the error message: Undefined reference to
class<T>::function()

Here is the source code that I use

in LIST.H

#ifndef LIST_H
#define LIST_H

template<class T> class List {
 private:
 public:
};

#endif

in list.cc

include "list.h"

// Implementations go here

in test.cc

include "list.h"

void main() {
 List<int> list;

//do list functions
}

Compile String 1 is: gcc -g -c list.cc -o useful.a // This works OK
Compile String 2 is: gcc test.cc useful.a -o test.exe // This give the
error

Any amount of help would be apprieciated


- Raw text -


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