
C++ Program of Friend functions having objects as arguments
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#include <iostream> using namespace std; class one { private: int n1=1; public: friend int add(one); }; int add(one object1) { return (object1.n1 + 1); } int main() { one object1; cout<<"Sum: "<< add(object1); return 0; } |