0
when I run this code am getting an error ,please help.why am getting an error at case(age<=age):
#include <iostream> using namespace std; int main() { int age = 4; switch (age) { case (age<=16): cout << "Too young"; break; case (age>=18): cout << "Adult"; break; case (age>=45): cout << "Senior"; break; } return 0; }
4 ответов
+ 1
case requires a constant expression. Which is to say, it's value has to be determined at compile time.
So you shouldn't use variable expressions inside case column
0
These isn't full code. Please paste full code.
0
please help
0
you pass an int into the switch but then have bools in the cases, see the problem here?