Thread: Friends...

  1. #1
    Aspiring "Software Guy"
    Join Date
    Aug 2005
    Posts
    46

    Friends...

    Please explain.

    "Friend Function does not have the class scope, rather it depends on the original declaration and definition"

    Does declaring frinds in public/private/protected make any difference?

  2. #2
    Registered User Noir's Avatar
    Join Date
    Mar 2007
    Posts
    218
    Nope, no difference at all.

  3. #3
    Aspiring "Software Guy"
    Join Date
    Aug 2005
    Posts
    46
    What about the quoted line. Please explain that too.

  4. #4
    Registered User Noir's Avatar
    Join Date
    Mar 2007
    Posts
    218
    A friend declaration is just a declaration of friendship, the scope and lifetime of the friend itself depends on where the friend is defined:
    Code:
    namespace Test {
      // has namespace Test scope
      void function1() {
      }
    }
    
    
    // has global scope
    void function2() {
    }
    
    
    class C {
      friend void function1(); // still namespace Test scope
      friend void function2(); // still global scope
    };

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Friends and Members
    By MarlonDean in forum C++ Programming
    Replies: 6
    Last Post: 06-18-2008, 11:52 AM
  2. Hello Friends , Help Me
    By RahulDhanpat in forum C Programming
    Replies: 3
    Last Post: 04-22-2006, 09:08 PM
  3. problem with friends
    By noob2c in forum C++ Programming
    Replies: 8
    Last Post: 09-15-2003, 07:43 AM
  4. Error: Friends must be functions or classes
    By pimming in forum C++ Programming
    Replies: 1
    Last Post: 06-10-2003, 05:31 PM
  5. Help me, Friends and Gurus ????
    By yescha in forum C Programming
    Replies: 3
    Last Post: 12-03-2001, 03:04 AM