How do you use an overloaded assignment operator to make a type int equal a custom type??? If possible, send links or examples. Need help desperately!!!!!!!
How do you use an overloaded assignment operator to make a type int equal a custom type??? If possible, send links or examples. Need help desperately!!!!!!!
Example below. I've overloaded the assignment operator.
If your class is derived from another, which already has an int assignment operator, just include your new operator.
Code:class MyClass { private: public: ... MyClass& operator =(int rhs); MyClass& operator =(const MyClass& rhs); ... };
where:
Code:MyClass& MyClass::operator =(const MyClass& rhs) { // Assign all contents form rhs to 'this' ... ... return *this; }
Last edited by Davros; 11-07-2002 at 07:18 AM.