Mastering C++: A Comprehensive Quiz Based on 'Thinking in C++'

Disable ads (and more) with a membership for a one time $2.99 payment

Test your C++ skills with our quiz based on Bruce Eckel's 'Thinking in C++'. Dive into object-oriented programming, advanced topics, and fundamentals. Perfect for learners and experts alike. Assess your knowledge and become a C++ master!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


Why do many people create function definitions with the opening brace on a new line?

  1. To match the official Java coding standard

  2. It was a requirement in pre-Standard C constraints

  3. For better alignment with class definitions

  4. To improve compile-time efficiency

The correct answer is: It was a requirement in pre-Standard C constraints

One possible explanation for why many people might create function definitions with the opening brace on a new line is because it was a requirement in pre-Standard C constraints. This means that in the past, it was necessary to have the opening brace on a new line in order for the code to be valid and compile correctly. Despite this requirement no longer being necessary in more current coding standards, the habit may have persisted due to familiarity or personal preference. The other options do not offer a clear explanation for this practice. Option A mentions the official Java coding standard, which does not necessarily apply to all languages and may not be the reason why some people choose to follow this convention. Option C mentions alignment with class definitions, which may not be relevant in the context of function definitions. Option D mentions compile-time efficiency, which is not directly related to the placement of the opening brace.