Tuesday 4 December 2012

Friend functions in C++



  Usually in C++, a function defined out side the Class can not access the member variables of a Class. But there might be occasions in which we have to allow access of Class member variables by non member functions. In C++ friend function is used to do such access. Friend functions are non member functions which can access data from the Class. You must be careful while using friend functions as this might allow even unwanted data to be accessed by outsiders.

Click here to download a C++ Program illustrating the working of a friend function.

No comments:

Post a Comment