In C++, by declaring function as friend function
2025
In C++, by declaring function as friend function
- A.
The function can use the private and protected members of the class
- B.
The function is in the scope of the class
- C.
The function must be invoked in an object
- D.
None of the above
Attempted by 49 students.
Show answer & explanation
Correct answer: A
A friend function in C++ is declared outside a class but granted access to its private and protected members. This allows non-member functions to interact directly with internal class data without being a member function themselves.