Exercise #12

Out: Friday November 8, 2013
Due: Wednesday November 13, 2013 by 11:15am.


Write a C++ program that:

Your implementation:

Here's an example that compiles and executes using a test file (whose contents are also shown):
bash$ g++ -Wall -std=gnu++0x -g -o reverse main.cc
bash$ cat ex12-testfile.txt
Function templates are special functions that can operate with generic
types.

This allows us to create a function template whose functionality can be
adapted to more than one type or class without repeating the entire
code for each type.
bash$ cat ex12-testfile.txt | ./reverse
 .epyt hcae rof edoc eritne eht gnitaeper tuohtiw ssalc ro epyt eno naht erom ot detpada eb nac ytilanoitcnuf esohw etalpmet noitcnuf a etaerc ot su swolla sihT .sepyt cireneg htiw etarepo nac taht snoitcnuf laiceps era setalpmet noitcnuF 
bash$ cat ex12-testfile.txt | ./reverse | ./reverse
 Function templates are special functions that can operate with generic types. This allows us to create a function template whose functionality can be adapted to more than one type or class without repeating the entire code for each type. 

Note: C++ likes to make copies. If you want to modify a data structure, say, you may not want C++ to make a copy, modify the copy, and then throw the copy away. One way to avoid copying in C++ is to use references.

We may test your code by supplying a mainline completely different from the one required by this writeup.


Your code must:

You should submit your reverse.h and main.cc files to the course dropbox.