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....

Recommended Answers

All 2 Replies

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.