Hi! All template related code (declarations and definitions) should be avaliable to the caller (main in your case) at compile time. I put your code into one file and it works fine. ---- Lev Assinovsky Aelita Software Corporation (now is a part of Quest Software) O&S InTrust Framework Division, Team Leader ICQ# 165072909 > -----Original Message----- > From: Andre Kirchner [mailto:supercroc1974@xxxxxxxxx] > Sent: Thursday, April 22, 2004 6:27 PM > To: gcc-help@xxxxxxxxxxx > Subject: simple error woth templates > > > Hi, > > I have made this program to learn templates, but gcc > keeps says that there's an undefined reference to > `Dog<int,long>::Dog[in-charge](int,int,long,log)` at > the line marked > bellow. > Could someone show me what's wrong? > > Thanks in advance, > > Andre > > > **** Dog.h ***** > > #ifndef IOSTREAM > #define IOSTREAM > #include <iostream.h> > #endif > > template < class CLASS_A, class CLASS_B > > class Dog > { > public: > Dog( CLASS_A firstNumber, CLASS_A secondNumber, > CLASS_B thirdNumber, CLASS_B forthNumber ); > ~Dog(){}; > void showBigger(); > > private: > CLASS_A number_A; > CLASS_B number_B; > }; > > > *** Dog.cpp *** > > #ifndef DOG > #define DOG > #include "Dog.h" > #endif > > template < class CLASS_A, class CLASS_B > > Dog< CLASS_A, CLASS_B >::Dog( CLASS_A firstNumber, > CLASS_A secondNumber, CLASS_B thirdNumber, CLASS_B > forthNumber ) > { > number_A = ( firstNumber>secondNumber > )?firstNumber:secondNumber; > number_B = ( thirdNumber>forthNumber > )?thirdNumber:forthNumber; > } > > template < class CLASS_A, class CLASS_B > > void Dog< CLASS_A, CLASS_B >::showBigger() > { > cout << number_A << endl; > cout << number_B << endl; > } > > > *** main.cpp *** > > #ifndef DOG > #define DOG > #include "Dog.h" > #endif > > int main( int argc, char *argv[] ) > { > Dog < int, long > theDog( 10, 20, 30l, 40l ); > > // theDog.showBigger; > > return( 0 ); > } > > __________________________________ > Do you Yahoo!? > Yahoo! Tax Center - File online by April 15th > http://taxes.yahoo.com/filing.html >