Does the following code contain errors?

void Test() {
  try {
    int i = 10, j = 20;  // 1
    throw int(10);  // 2
  }
  catch (...) {  // 3
    i = 20;  // 4
    int j = 20;  // 5
  }
}
Explanation
Try and catch blocks have disjoint scopes, therefore line //4 contains an initialization of yet undeclared variable.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback