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

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

Master C++ with our comprehensive quiz based on 'Thinking in C++'. Test your knowledge through flashcards and multiple-choice questions to enhance your understanding of C++. Prepare effectively for your exam!

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.


What must be done before 'oneChar()' can return characters from the string 'a'?

  1. Call 'oneChar()' with no arguments

  2. Call 'oneChar(a)' to initialize 's' to 'a'

  3. Declare 'a' as a global variable

  4. Manually set 's' to the start of 'a'

The correct answer is: Call 'oneChar(a)' to initialize 's' to 'a'

Before 'oneChar()' can return characters from the string 'a', the function must first be initialized with the string 'a'. This is done by calling 'oneChar(a)' which will set the value of 's' to be equal to 'a'. Option A is incorrect because simply calling 'oneChar()' without any arguments will not initialize 's' to the string 'a'. Option C is incorrect because declaring 'a' as a global variable does not automatically set the value of 's' to be equal to 'a'. Option D is incorrect because manually setting 's' to the start of 'a' does not initialize the function with the string 'a'.