标签: c++ overloading assignment-operator
int i; Integer a; //a class object i=a; //here a's member variable value should be assigned to 'i'
答案 0 :(得分:5)
您可以通过提供从班级到int的转化运算符来实现此目的:
int
class Integer { // ... stuff public: operator int() const { return member_to_assign; } };