templates
templates
- Subject: templates
- From: Francisco Tolmasky <email@hidden>
- Date: Thu, 02 Oct 2003 00:52:03 -0700
Ok, I'm using objective-C++ so part of my program uses C++ templates.
I have a class structure something like this:
in safe.hpp:
//all the ifndef stuff
template<typename T>
class safe
{
protected:
virtual void read(const char * str)= 0;
};
//endif
in primitive.hpp:
//all the ifndef stuff
template<typename T>
class primitive: public safe<T>
{
protected:
virtual void read(const char * str) { std::cout<< "undefined" }
};
template<>
void primitive<int>::read(const char * str)
{
//turns string into int.
}
//endif
The problem is my specialization (primitive<int>). For some reason it
makes an error of "multipel definitions of symbol
primitive<int>::read(char const *). I tried it in Codewarrior and it
did the same thing. I really can't figure it out. I know it's
something that I'm doing wrong with templates and specifically template
specialization but I don't know what! I include primitive.hpp in
several places but I have the inclusion guards. I read somewhere about
multiple instances of templates being global or something?
ANY help is GREATLY appreciated,
thank you,
Francisco Tolmasky
email@hidden
http://users.adelphia.net/~ftolmasky
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.