[Dev-C++] Templates, Dev-Cpp and C++
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Maya <Esc...@ne...> - 2003-12-28 05:21:59
|
This is my first 'class template', so I am sure I am doing something
wrong. Can anyone help?
TIA
------ file.H ------
namespace jme{
template<class K, class D>
class Index{
protected:
K Key;
D Data;
public:
// C'tor
Index(K kx, D dx);
~Index();
};
}
------ file.C ------
template<class K, class D>
jme::Index<K,D>::Index(K kx, D dx){
Key = kx;
Data = dx;
}
template<class K, class D>
jme::Index<K,D>::~Index(){ }
------ main.C ------
int main(){
int i = 50;
std::string name("Maya");
jme::Index<int, std::string> ndx(i,name);
return 0;
}
------ Error message ------
main.o(.text+0xb9):main.C: undefined reference to `jme::Index<int,
std::string>::Index(int, std::string)'
main.o(.text+0x12c):main.C: undefined reference to `jme::Index<int,
std::string>::~Index()'
main.o(.text+0x152):main.C: undefined reference to `jme::Index<int,
std::string>::~Index()'
--
FYI
http://www.astro.umd.edu/~marshall/abbrev.html
E-Mail Policy
http://www.vif.com/users/escalante/Email_Policy.html
|