#include<string>
#include<iterator>
#include<vector>
#include<iostream>
int main(){
std::string str = "abc";
std::string str2 = str;
std::vector<int>::reverse_iterator rit = str.rbegin();
for(rit+1; rit != str.rend(); rit++){
str2.push_back('*rit');
}
std::cout << str2 << std::endl;
}
I expected the output to be 'abcba', but there seems to be an error in push_back(). Somebody help me T_T
For starters there is a typo (or you wanted to highlight the expression)
It seems you mean
This declaration
does not make a sense. The declared object and the right expression used as an initializer have different types and there is no implicit conversion between them.
What you need is the following
Or you could write
Or the for loop could be written like