Saturday, April 11, 2015

C++ friend functions


Friend functions are defined within a class that enable these functions outside the class to access the function and data within the object.  The function can be a C++ function or a operator-overload function

Class C {
    friend void fn (...)  // a normal function
    friend a& operator<<(..._  // operator overloading of <<
    .... // normal class definition
}

Friend functions are declared outside of the class  

No comments: