
C++ Friend Function Quiz

Quiz
•
Other
•
•
Hard
MARY T
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is a friend function in C++?
A friend function in C++ is a function that can only be called from within the class.
A friend function in C++ is a function that can only access the public members of a class.
A friend function in C++ is a function that has access to the private and protected members of a class.
A friend function in C++ is a function that can be called from any other class except the one it is declared in.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the syntax of a friend function in C++?
friend return_type function_name(parameters);
friend return_type function_name;
friend function_name;
friend function_name(parameters);
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How can a friend function access private members of a class in C++?
By being declared as a friend inside the class
By using the 'static' keyword
By using the 'protected' access specifier
By using the 'public' access specifier
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Can a friend function be a member of a class hierarchy in C++?
No
Yes
Sometimes
Only in certain cases
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the difference between a friend function and a member function in C++?
A friend function is not a member of a class, while a member function is a member of a class.
A friend function can be called without an object, while a member function can only be called using an object.
A friend function is declared inside a class, while a member function is declared outside the class.
A friend function can only access public members of a class, while a member function can access both public and private members.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
True or False: A friend function can access protected members of a class in C++.
False
True
Only if the friend function is a member of the class
Only if the friend function is declared in the same file as the class
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
True or False: A friend function can be declared in the private section of a class in C++.
Only in derived classes
False
True
Only in public section
Create a free account and access millions of resources
Similar Resources on Wayground
10 questions
C++ set4

Quiz
•
University
11 questions
Data Protection/GDPR/Computer Misuse

Quiz
•
8th - 10th Grade
15 questions
Java OOP Quiz

Quiz
•
KG - University
15 questions
Quiz 3 - Communication Research Methods

Quiz
•
University
15 questions
CX-Test 26SEP

Quiz
•
Professional Development
10 questions
Setting goals

Quiz
•
KG - 5th Grade
10 questions
Appositives Quiz

Quiz
•
5th Grade
14 questions
OneNote

Quiz
•
3rd Grade
Popular Resources on Wayground
50 questions
Trivia 7/25

Quiz
•
12th Grade
11 questions
Standard Response Protocol

Quiz
•
6th - 8th Grade
11 questions
Negative Exponents

Quiz
•
7th - 8th Grade
12 questions
Exponent Expressions

Quiz
•
6th Grade
4 questions
Exit Ticket 7/29

Quiz
•
8th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade
20 questions
One Step Equations All Operations

Quiz
•
6th - 7th Grade
18 questions
"A Quilt of a Country"

Quiz
•
9th Grade
Discover more resources for Other
50 questions
Trivia 7/25

Quiz
•
12th Grade
11 questions
Standard Response Protocol

Quiz
•
6th - 8th Grade
11 questions
Negative Exponents

Quiz
•
7th - 8th Grade
12 questions
Exponent Expressions

Quiz
•
6th Grade
4 questions
Exit Ticket 7/29

Quiz
•
8th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade
20 questions
One Step Equations All Operations

Quiz
•
6th - 7th Grade
18 questions
"A Quilt of a Country"

Quiz
•
9th Grade