C++ 23 · Language basics
Declare a variable in an if
Limit a variable's scope to the if and else branches.
if (auto it = scores.find("Ada"); it != scores.end()) {
std::cout << it->second << '\n';
}
C++ 23 · Language basics
Limit a variable's scope to the if and else branches.
if (auto it = scores.find("Ada"); it != scores.end()) {
std::cout << it->second << '\n';
}
Was this page helpful?