-
A small Question
My teacher say's CALL is the most expensive subroutine, and costs the most overhead, and that is why we use a friend function (according to her, it reduces the overhead by reducing the number of CALLs. But books don't mention this. They say a friend function is to be used when we need objects of two different classes, and mention nothing about CALLs. I am a bit confused as to who I believe, the textbook, or the teacher.
Could someone help me, or give me a link to some webpage, where I can actually see how and when friend functions are to be used (not what friend functions are).
Thanx.
-
You should only grant friendship when there is no other way. A friend can have access to a classes internals and so breaks encapsulation. Sometimes this really is necessary but its use should be kept to a minimum with proper design.
-
you're teacher is way off base if you're understanding her correctly. friend is just something that allows access to private and protected parts of a class. Perhaps inline is what she's looking for? Even then you shouldn't over-do you're inlines.