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!!!!!!!
This is a discussion on overloaded operators within the C++ Programming forums, part of the General Programming Boards category; How do you use an overloaded assignment operator to make a type int equal a custom type??? If possible, send ...
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 06:18 AM.