You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In C++, a friend function is a function that is not a member of a class but is granted special access to the private and protected members of that class.
7
+
Friend functions are often used when you need to allow an external function or another class to access the private data of a class without making those data members public.
cout<<"Parameterized constructor for "<<real<<" +i* "<<imaginary<<endl;
19
+
}
20
+
21
+
voiddisplay()
22
+
{
23
+
cout<<real<<" +i* "<<imaginary<<endl;
24
+
}
25
+
26
+
friend Complex operator+(Complex c1, Complex c2); // this friend function is not a member function of the class , but it can access all members of the class, including private or protected without need to change them to public
0 commit comments