Now I writing about TTS program. I already got the TTS function from the Microsoft word.
but Now I effort to write for MS Excel. The following is a piece of code of MSWord.
But this partial spezialitation is to use the same template function with different typenames but doing differnt things if one type or another? or to support different typenames with the same functionality?
I think I don't understand you correctly.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
mmm...according to the typenames I must write some variations in some class member.
In my case the typenames are classes, similar, but not exactly the same...so somethimes I have to write (in the parent class) different behaviour using different member function, but to do the same thing.
The second typename (B in the example of the first message can be 'double' 'int' 'CString' ....)
It's hard to explain everything but I want to be sure that with this 'partial' specialization I can solve the problem. I have only to find the correct sintax, Unfortunatly I'm not so expert on templates and I use they not so often.
I don't work very often with that kind of things but I think that template specialization only works at the class level, not at the method level: you need to specialize your class and there, you can override the functions you like.
I think, in your situation it will be like this:
template <typename B><br />
class CMyClass<MyTypeName,B><br />
// Here you define the functions you want to override<br />
I'm not 100% sure thought, so you'll have to check.
sure...in that way it could work, but I prefere to use a simple "template specialization" it works well if all typenames must be specialized. But this is the first time that I have to specialize only a typename, so I I'm trying to find the correct sintax.
thanks for your time
AFAIK it is because template code is generated by your compiler. It means that when you have a template instantiation (something like list<float> ) your compiler will generate code corresponding to this template type. To be able to generate the code, it needs the complete function implementation.
You do *not* have to have definitions in th ecpp.
You do this to (partially) separate interface and implementation.
With templates, every instantiation (for type A, type B etc) creates a new, distinct type: vector<A> is different from vector<B>.
And for this instantiation, the compiler needs the complete definition of the template. Therefore it is easiest to put the template in the header, to have it ready when you need it.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words