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

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

Challenge your C++ knowledge with a comprehensive quiz based on 'Thinking in C++'. Explore a variety of multiple choice questions with hints and explanations to solidify your understanding. Get prepared!

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.


Can C++ overload functions based on their return type alone?

  1. Yes, always

  2. No, never

  3. Only if the function has arguments

  4. Only in templates

The correct answer is: No, never

C++ cannot overload functions based on their return type alone. Overloading functions requires that they have different parameters, not simply different return types. This means that options A and C, which suggest that overloading based on return type is sometimes possible, are incorrect. Option D is not correct because templates involve type parameters rather than return type parameters, and therefore cannot be used to overload based on return type.