When compiling the following:
template <class T>
class Number
{
private:
T num;
public:
Number() {}
Number( T n ) : num(n) {}
operator T() const { return num; }
};
int main()
{
Number<int> n=5;
Number<char> c=4;
int i;
c=int(5);
i=n;
c=n;
return 0;
}
The compiler gets stuck at the third assignment saying there is no match for operator= in c=n. Shouldn't n get converted to int, which in turn will be assigned to c?