15,129 views
2 votes
2 votes
If class A is friend of class B and if class B is friend of class C, which of the following is true?

a. Class C is friend of class A

b. Class A is friend of class C

c. Class B cannot be a friend of any other class

 d. None of the above

1 Answer

1 votes
1 votes

Property of friend classes is not transitive. If class A is friend of class B, and B is friend of C, then A is never a friend of C unless expilictly declared so. Property of friendship is not corresponding / commutative. If A is a friend of B, then B is not a friend of A. Functions of class A can have access to private / protected data of B without becoming member functions of B, but the converse is not true. So opions (a) and (b) are wrong. It is not that class B cannot be a friend of any other class. It can have a friendship with A while continuing friendship with C. So option (c) is also not correct.

Hence, none of the statments are true. Answer is option (d).

Related questions

2 votes
2 votes
0 answers
1
sh!va asked Aug 9, 2016
1,045 views
Which of the following is (are) not recommended in a header file?a. Type definitions (typedefs)b. Class definitionsc. Function definitionsd. Template definitionsI. d only...
2 votes
2 votes
1 answer
2
sh!va asked Aug 11, 2016
313 views
What fearure(s) can differ between two overloaded functions?a. Number of parametrsb. type of parametersc. Return type.I. a , b, or cII.( a and b) or cIII. a and b onlyIV...
1 votes
1 votes
1 answer
4
Harikesh Kumar asked Jan 14, 2018
287 views
Output is? With explanation