Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualKhatharr

Posted 06 May 2013 - 02:31 PM

A friend prototype works as a declaration in the scope of the class.
 
 
class Foo {
  friend void bar(); //declaration
};
 
void bar() {
 //definition
}
 
just like
 
 
void foobar(); //declaration
 
void foobar() {
  //definition
}
What friend does is that the function prototyped has access to all of the class' members, even the private or protected ones. It's an external function with internal access. Your book is just doing a poor job of explaining it.

#1Khatharr

Posted 06 May 2013 - 02:28 PM

A friend prototype works as a declaration in the scope of the class.

 

class Foo {
  friend void bar(); //declaration
};
 
void bar() {
 //definition
}

 

just like

 

void foobar(); //declaration
 
void foobar() {
  //definition
}

PARTNERS