From: Shue-Cheng CHEN Newsgroups: comp.os.msdos.djgpp Subject: A Problem with Template Class Date: 25 Sep 1998 07:09:18 GMT Organization: Graduate School of Engineering, The Univ. of Tokyo, Japan. Lines: 43 Message-ID: <360B4190.1C2DD19F@ohriki.t.u-tokyo.ac.jp> NNTP-Posting-Host: chen.ohriki.t.u-tokyo.ac.jp Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Hi! I made a main program "test.cc" as follows, #include #include "simarra.h" // Header for SimpleArray int main() { SimpleArray a; for (int i=1; i<=6; i++) { a[i] = i * 1.1; cout << a[i] << " "; } cout << endl; return 0; } It's strange that this main program only works when I placed all implementations of the class SimpleArray in the same test.cc. When the implementations of the main program and the class were separated in two different files, e.g., test.cc and SimArra.cc, in the linking stage, I always got the messages 1.o: In function `main': 1.cc:1: undefined reference to `SimpleArray::SimpleArray(void)' 1.cc:2: undefined reference to `SimpleArray::SimpleArray(void)' 1.cc:6: undefined reference to `SimpleArray::operator[](int)' 1.cc:7: undefined reference to `SimpleArray::operator[](int)' 1.cc:11: undefined reference to `SimpleArray::~SimpleArray(void)' 1.cc(.text+0xc9): undefined reference to `SimpleArray::~SimpleArray(void)' 1.cc(.text+0xf3): undefined reference to `SimpleArray::~SimpleArray(void)' 1.cc(.text+0x113): undefined reference to `SimpleArray::~SimpleArray(void)' Why did it become undefined? Thank you in advance. Shue-Cheng Chen