Friends...

This is a discussion on Friends... within the C++ Programming forums, part of the General Programming Boards category; Please explain. "Friend Function does not have the class scope, rather it depends on the original declaration and definition" Does ...

  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, 12:52 PM
  2. Hello Friends , Help Me
    By RahulDhanpat in forum C Programming
    Replies: 3
    Last Post: 04-22-2006, 10:08 PM
  3. problem with friends
    By noob2c in forum C++ Programming
    Replies: 8
    Last Post: 09-15-2003, 08:43 AM
  4. Error: Friends must be functions or classes
    By pimming in forum C++ Programming
    Replies: 1
    Last Post: 06-10-2003, 06:31 PM
  5. Help me, Friends and Gurus ????
    By yescha in forum C Programming
    Replies: 3
    Last Post: 12-03-2001, 03:04 AM

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