Thread: A small Question

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    42

    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.
    First hear, then understand, and then, leaving all distractions, shut your mind to outside influences and devote yourself to developing the truth within you.

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    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.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    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.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  2. Hi all, I have a small question...
    By Pandora in forum Windows Programming
    Replies: 3
    Last Post: 03-16-2003, 06:21 AM
  3. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  4. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 03:57 PM
  5. what does this warningmean???
    By kreyes in forum C Programming
    Replies: 5
    Last Post: 03-04-2002, 07:53 AM