关于友元函数的优缺点(on advantage and disadvantage of friends' function)

a summary of c++ friends' function
in fact, there are probable the following two situations needs to use the friends' function:
(1)some occasions of operator overloading needs to use friends' function
(2)two classed need to share data
the advantage and disadvantage of using friends' function
advantage: can improve efficiency, simple and clear expres
disadvantage:friends' function break the encapsulation mechanism

转载于:https://www.cnblogs.com/1915884031A-qqcom/p/7670494.html

你可能感兴趣的:(关于友元函数的优缺点(on advantage and disadvantage of friends' function))