Skip to content

Latest commit

 

History

History
95 lines (57 loc) · 1.52 KB

CppSwitch.md

File metadata and controls

95 lines (57 loc) · 1.52 KB

 

 

 

 

 

 

switch is a keyword to perform a kind of multiple if statements on a certain value. case determines which values can be switch on. If there is no named value to switch on, default can be used optionally.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  1. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 9.8. Advice, page 240: '[2] Prefer a switch-statement to an if-statement when there is a choice'
  2. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 22.7. Advice. page 663: '[10] Prefer virtual functions to repeated switch-statements based on typeid or dynamic_cast'