// Code derived from Stroustrup's PPP2 book// § 4.6.4 A text example// -and beginning on p 123#include<algorithm>#include<iostream>#include<string>#include<vector>usingstd::cin;usingstd::cout;usingstd::string;usingstd::vector;template<typenameC>voidsort(C&c){std::sort(begin(c),end(c));}// simple dictionary: list of sorted wordsintmain(){cout<<"Please enter words: ";// note: see input stream comments on p 124// (ie, use ctrl+d to end input of strings)vector<string>words;for(stringtemp;cin>>temp;)// read whitespace-separated wordswords.push_back(temp);// put into vectorcout<<"Number of words: "<<words.size()<<'\n';sort(words);// sort the wordsfor(unsignedinti=0;i<words.size();++i)if(i==0||words[i-1]!=words[i])// is this a new word?cout<<words[i]<<'\n';}