Re: [Dev-C++] Templates, Dev-Cpp and C++
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Abdelkader G. <go...@li...> - 2003-12-28 13:40:08
|
Hi there,
Your code is well written, it should compile and run, just check that you
have compiled correctly the 'file.C' (rename it to .cpp :) or delete all
old *.o files and recompile all the project.
Kind regards,
> 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
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: IBM Linux Tutorials.
> Become an expert in LINUX or just sharpen your skills. Sign up for
> IBM's Free Linux Tutorials. Learn everything from the bash shell to
> sys admin. Click now!
> http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|