Write a C++ program that:
Your implementation:
#include#include #include #include #include #include "reverse.h" using namespace std; int main(int argc, char* argv[]) { // declare a vector of strings here while ( cin.good() ) { // read a token from cin and put it at the tail of the vector of strings } // Reverse worldVec here // Reverse the characters in each word of wordVec here // Print out the tokens in wordVec, separated by a single space return EXIT_SUCCESS; }
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.