Clarification needed
What is the meaning of the words (term) "falling through" in C++? Please try to list some conditions that would cause this to happen.
1 2 3 4 5 6 7 8 9
|
switch (i) {
case 1:
x = 1;
case 2:
y=2;
break;
case 3:
z = 3;
}
|
In this statement, control "falls through" from case 1 to case 2. In other words, if i==1 then it will execute the code for case 1 AND case 2.
So in reality it is actually dropping down to the next level. I guess it makes sense when they say it is falling through. That's pretty simple
Thank You for taking the Time to explain that.
Topic archived. No new replies allowed.