Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A friend function has access only to the private members and member of the class

ID: 3583406 • Letter: A

Question

A friend function has access only to the private members and member of the class (and all objects of that class) of which it is friend. True False Which of the following defines the c-string containing "Hello" (multiple answers) char stringVar[] = "Hello'; char stringVar[10] = "Hello"; char stringVar[6] = "Hello"; char stringVar[10] = {'H', 'e', T, T. 'o', 0}; char stringVar[10] = {'H', 'e', T, T, 'o'}; If you want to examine an input value without actually removing it from the input stream, you can apply a member function of cin to the variable ch which you are to assume is a variable. Which of these does this task? cin putback (ch); cin get(ch); cin peek(ch); cin put(ch);

Explanation / Answer

16. A friend function has access only to the private members and member functions of the class
(and all objects of that class) of which it is a friend.
False. A friend function has access to all the private and protected members of the class.

17. Which of the following defines the C-string containing "Hello"?
a. char stringVar[] = "Hello";  
b. char stringVar[10] = "Hello";
c. char stringVar[6] = "Hello";
d. char stringVar[10] = {'H', 'e', 'l', 'l', 'o', ''};
e. char stringVar[10] = {'H', 'e', 'l', 'l', 'o'};
All these will do the needful, but the last option e, may sometimes behave weird.

18. If you want to examine an input value without actually removing it from the input stream,
you apply a member function of cin to the variable ch, which you are to assume is a char
variable. Which of these does this task?
c. cin.peek(ch); will achieve the needful.

19. If you have already removed a character (in char variable ch) from the input stream,
you can apply a member function of cin to the variable ch, to return it to the input stream.
Which does the task?
a. cin.putback(ch); will do the needful.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote