You are here:

  • Home
  • Computing/Technology
  • C/C++
  • C++
  • Maximum of Case Labels (1, 2...) for A Switch Statements and Maximum of Selection Control Structures (Else if) inside of each Case Labels of Switch Statements

C++/Maximum of Case Labels (1, 2...) for A Switch Statements and Maximum of Selection Control Structures (Else if) inside of each Case Labels of Switch Statements

Advertisement


Question
Hello vijayan,

I have two questions below and hope you can help me to answer them. I will never forget you.

Question # 1:
  How many maximum Case Labels (1, 2,..) for Switch
  Statements are there in C++?.

Question # 2:
  If I use the selection control structures as else if
  inside of each Case Label for Swicth Statements, how
  many maximum of else if statements in this case are
  there in C++?.

Notes: Both the Case Labels for Switch Statements and Else If Statements are coding inside of the main program.

Thanks,
Jonathan Tran

Answer
C++ specifies no limits on the number of case labels, or on the nesting level of control structures.

However, Appendix B of the standard has this to say:

Computer memory is finite and C++ implementations are inevitably limited in the size of the programs they can successfully process. Every implementation shall document those limitations where known.
...
The bracketed number following each quantity is recommended as the minimum for that quantity.  

Nesting levels of compound statements, iteration control structures, and selection control structures [256]
...
Case labels for a switch statement (excluding those for any nested switch statements) [16384]
...

Every mainstream C++ implementation would allow at least this much.  

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


vijayan

Expertise

my primary areas of interest are generic and template metaprogramming, STL, algorithms, design patterns and c++11. i would not answer questions about gui and web programming.

Experience

about 15 years or so

Education/Credentials
post graduate engineer

©2016 About.com. All rights reserved.