I need a help in coding this program...
write a C++ program to read a set of n numbers where n is defined by the user and print the contents of array in the reverse order using class template, numbers should include int and double data types...
please reply soon....

4 Years
Discussion Span
Last Post by rubberman

We don't do people's homework here. You have to show that you are actively trying to solve the problem on your own, and ask specific questions about your code and how to fix it. Please show what you have done.

I would advise that you just start by trying to solve the problem without templates.. i.e., just do it for "int", and then, make it a template afterwards, when you know it works.


What Mike2k said. Template functions are what you can call "generic programming". You develop an algorithm that works for multiple types, and then code it as a template. Instead of a separate function for each type you want to apply the algorithm to, you only have one template function, and it does the "right thing" for each appropriate type of data you pass to it. A couple of examples would be min/max/avg functions that operate on integers, floating point values, etc. Instead of having a separate function for each type, you only need one, the template function.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.