Practice Exercise #6

Implement a single C++ source file, reverse.cc that:

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 reverse.cc
bash$ cat 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 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 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 that C++ likes to make copies, and that if you want to modify a data structure, say, you don't really 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.