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!

Practice this question and more.


What must be true for two functions to be considered overloaded in C++?

  1. They must have different return types

  2. They must belong to the same class

  3. They must have different number or types of parameters

  4. They must perform different operations

The correct answer is: They must have different number or types of parameters

For two functions to be considered overloaded in C++, it is necessary that they have different number or types of parameters. This means that the functions must differ in the arguments they can take, which allows them to be called with different types of data. Option A is incorrect because two functions can have the same return type but still have different parameters, which would make them overloaded. Option B is incorrect because the functions do not have to belong to the same class to be considered overloaded. Option D is incorrect because two functions can have the same number of parameters and still perform different operations, which would not meet the requirement for overloading.