Friend Function

This is a discussion on Friend Function within the C++ Programming forums, part of the General Programming Boards category; What is the purpose of friend function, I know it has access to the private section. But what is it ...

  1. #1
    Registered User
    Join Date
    Sep 2006
    Location
    Kansas City
    Posts
    76

    Friend Function

    What is the purpose of friend function, I know it has access to the private section. But what is it the difference between it and using a class member function?

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Your friends can touch your privates!
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    Sep 2006
    Location
    Kansas City
    Posts
    76
    That's what I said, but what its point since I can just use a class member function ?

  4. #4
    Registered User IdioticCreation's Avatar
    Join Date
    Nov 2006
    Location
    Lurking about
    Posts
    229
    Hey Such, on that article he posted, scroll down till you see:
    [14.5] Should my class declare a member function or a friend function?

    Is that what you are looking for?

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    7,318
    Dave_Sinkula's link has more information on your question.

    In short, you cannot always use a class member function, as is the case with operator<<. Also, classes can be friends, and you cannot nest a class inside more than one other class.

  6. #6
    Registered User
    Join Date
    Sep 2006
    Location
    Kansas City
    Posts
    76
    Yeah thats it, I did not even knew that it was a link.

    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 08:28 AM
  2. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  5. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-01-2003, 11:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21