Small change to my last e-mail. After a little more reading I have come across the line
"A user-defined specialization looks like an ordinary template definition except that it must appear after its primary template."
In other words:
template <typename T>
T Operation(T value)
{ return value; }
template<> int Operation(int val)
{ return val; }
won't work but:
template <typename T>
T Operation(T value)
{ return value; }
template<> int Operation(int val)
{ return val; }
should work. My earlier comment about the template declaration and the function header being on different lines is just a sign of my lack of sleep.
Hope this helps some more
David McKen
----- Original Message -----
From: Pillati
To: dev...@li...
Sent: Sunday, October 05, 2003 6:20 PM
Subject: [Dev-C++] problems with template especialization
Hi!
I am trying to do with that a member method of a template class calls another method (with explicit specialization) that doesn't belong that class and it is defined in the same file. However, I obtain the following error: "multiple definition of 'int Operation(int)' ". Why doesn't this code work?
//Image.cpp
template <typename T>
T Operation(T value)
{ return value; }
template<> int Operation(int val)
{ return val; }
// member method of template class
template <typename Type>
void Image<Type>::setData()
{
int a;
a = Operation(10);
}
Raquel.
------------------------------------------
Use o melhor sistema de busca da Internet
Radar UOL - http://www.radaruol.com.br
---------------------------------------------------------------------
Please read http://www.wxwindows.org/mlhowto.htm before posting.
To unsubscribe, e-mail: wx-...@li...
For additional commands, e-mail: wx-...@li...
________________________________________________
Este E-mail foi enviado Usando o Software DETECMAIL 1.0
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ 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
---------------------------------
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search |