addition expressions? List the candidate functions, the viable functions, and the type conversions on the arguments for each viable function:
struct SmallInt {
SmallInt(int);
operator int() const { return val; }
private:
std::size_t val;
};
SmallInt operator+(const SmallInt&, const SmallInt&);
struct LongDouble {
LongDouble operator+(const SmallInt&);
LongDouble(double = 0.0);
operator double();
operator float();
};
LongDouble operator+(LongDouble&, double);
SmallInt si;
LongDouble ld;
ld = si + ld;
ld = ld + si;
https://github.com/chandradeepdey/C-_Primer_5th/blob/master/14/14.52.txt someone please verify my answer, overload resolution is causing brain damage ;-;
i cheated and looked on godbolt, the first one get an ambiguous overload error https://gcc.godbolt.org/z/Jkuv5w
it's always small to big... but here SmallInt... (I didn't cheat, if I am wrong I welcome the learning)
Обсуждают сегодня