C++ Friend Function Quiz

C++ Friend Function Quiz

10 Qs

quiz-placeholder

Similar activities

C++ set  3

C++ set 3

University

10 Qs

Quiz 3 - Communication Research Methods

Quiz 3 - Communication Research Methods

University

15 Qs

Setting goals

Setting goals

KG - 5th Grade

10 Qs

LIP 173 – Learning Management System (LMS) - MOODLE

LIP 173 – Learning Management System (LMS) - MOODLE

Professional Development

10 Qs

CFC Promotion Quiz

CFC Promotion Quiz

5th - 12th Grade

15 Qs

Pitcher Classroom Expectations

Pitcher Classroom Expectations

KG - University

15 Qs

Google Chat - Facts Check!

Google Chat - Facts Check!

Professional Development

15 Qs

C++ Friend Function Quiz

C++ Friend Function Quiz

Assessment

Quiz

Other

Hard

Created by

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

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?