Hello,
i want to know the reason as to why can't the = operator be overloaded with friend function of the class?why do we only have to use the member function??
this is the code :-
Code:#include <iostream.h> class set { int data; public: void getdata(int); void putdata(); void operator=(set); }; void set::getdata(int a) { data=a; } void set::putdata() { cout<<data; } void set::operator=(set b) { data=b.data; } int main(void) { set a,b; a.getdata(5); a.putdata(); b=a; cin.ignore(); cin.get(); return 0; }



LinkBack URL
About LinkBacks



CornedBee