Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) if

 

if is a keyword to allow conditional program flow.

 

A Yoda condition is a type of if-statement.

 

 

 

 

Example

 

 

 

 

 

 

Advice

 

 

 

 

 

 

References

 

  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. Paul Deitel, Harvey Deitel. C++11 for programmers (2nd edition). 2014. ISBN: 978-0-13-343985-4. Chapter 2.6, Common Programming Error 2.4. page 34: 'Placing a semicolon immediately after the right parenthesis after the condition in an if statement is often a logic error (although not a syntax error)'

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict