C ++ Primer exercise 9.35 provides the following answers: [cpp] # include <iostream >#include <cctype >#include <string> using namespace std; int main () {<span style = "color: # ff0000;"> string str = "This is a Example"; </span> for (string: iterator iter = str. begin (); iter! = Str. end (); ++ iter) {if (isupper (* iter) {str. erase (iter); -- iter; }}for (string: iterator iter = str. begin (); iter! = Str. end (); ++ iter) cout <* iter <""; return 0;} or above. Solution: since the first letter is T, -- iter -- ite, r is out of the iteration range. Change it to string str = "this is A exaMple"; as follows, you can use [cpp] # include <iostream> # include <cctype> # include <string> using namespace std; int main () {string str = "this is A exaMple"; for (string: iterator iter = str. begin (); iter! = Str. end (); ++ iter) {if (isupper (* iter) {str. erase (iter); -- iter; }}for (string: iterator iter = str. begin (); iter! = Str. end (); ++ iter) cout <* iter <""; return 0 ;}