Facing problem in declaring template function.This is first ever program i have written for learning the concept of c++ templates. Following program is from text-book.Even though it is from text-book, i am facing errors.Try it please and suggest me.
Okay.You were right ! There is inbuilt function swap in std. Thanks to both of you."EssGeEich" in your comment by mentioning typename you want to emphasis that i should declare it as like this template <int T> ??? or if something else then i am unfamiliar with the keyword "typename" Kindly give me some reference for it.Thank you once again.
No, in that case you should exactly substitute 'class' with 'typename'. In this context, they do the same thing, but it is better to use the keyword 'typename'.
Cplusplus Templates Tutorial Page wrote:
The only difference between both prototypes is the use of either the keyword class or the keyword typename. Its use is indistinct, since both expressions have exactly the same meaning and behave exactly the same way.
But in certain cases, going further, you will have a difference between typename and class.