c++ - I want to overload "=" operator to assign value from an object to a non class int variable -
this question has answer here:
int i; integer a; //a class object i=a; //here a's member variable value should assigned 'i'
you can providing conversion operator class int
:
class integer { // ... stuff public: operator int() const { return member_to_assign; } };
Comments
Post a Comment