I have some problem with program maybe some one can help me . So:
int main() {
std::string col = "maly tekst"
for_each(/* FILL IN #2*/ f());
copy(/*FILL IN #3*/);
std::cout << col; }
Output should be : TSKET YLAM
I know that i need to use Functor so i made something like this :
#include <iostream>
#include <string>
#include <algorithm>
class f{
public:
void operator() (char &k)const
{
k = toupper(k);
}
};
int main(){
std::string col = "maly tekst";
for_each(col.begin(),col.end(),f());
copy(col.rbegin(),col.rend(),back_inserter(col));
std::cout << col << std::endl;
}
But now when i run it it returns :
MALY TEKSTTSKET YLAM
Can some one point me on right way , or help me with this example program ?
Thanks
E: Forgot to add that I can only use this functions in main , I cant add anything new
You can’t use std::copy to replace original container if you can’t use
std::reverse. To print col withreverse order, another work around is to copycoltostream iteratordirectly.