0
Why is the error being given? [SOLVED]
When this code runs, an error is given. Why? https://code.sololearn.com/cEa7Qbs6oVZF/#cpp
6 Respuestas
+ 3
str b;
b = "bob";
and
str st;
st = " b ";
+ 1
Not 100% sure,....but could be your trying to assign to something that not been created yet....someone maybe able to clarify....consider using a constructor in you class.
There's something wrong with your 'strip' method too....comment it out and the last two "print" output ok.
+ 1
@rodwynnejones, yes... i am aware of them. I am currently fixing them.
+ 1
In line 82 u put semicolon
cout << b.count('b');<< endl;
Remove this semicolon which is showing in mid b.count('b')
0
@rodwynnejones
Wha-
Why does it work when I just change that?
0
For your strip method....declare a temp string and append the string elements to the temp if it is NOT a space...then... assign the temp string back into original string.
(not sure if that is the best way..but that's how I managed to do it).