Please Help I'm so close to finishing this huge project. I don't understand an error I'm receiving
score-=(double)atof(kitty.pop_front());
!invalid use of void expression
kitty is a deque type string. Score is a long double. I'm not good with type conversions but the error seems really unrelated?
I tried other forum's solutions but they are all relatively unrelated.
dequeue::pop_front() returns void:
void pop_front();
So you can't use it in an expression that way.
You could instead do:
score-=(double)atof(kitty.front().c_str());
kitty.pop_front();
If the value in the deque
is std::string
, the atof
function call should be:
score -= atof(kitty.front().c_str());
The reason is that atof
expects a const char*
parameter, and std::string::c_str()
returns a const char*
that represents the string.
Second, the front()
function returns the value that is at the front of the deque. If you want to remove the value from the front
, then you call kitty.pop_front()
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.