Type conversion using Operator overloading

Type conversion using Operator overloading

The type conversions are automatic only when the data type involved are built-in types.
int m;
float x= 3.012
m=x; // convert c to integer before its value is assigned t m.

For user-defined data types, the compiler does not support automatic type conversations.

We must design the conversion routines by ourselves.
  • Three situations for incompatible matches

    • From built in type to a class type
    • From class type to built-in type
    • From one class type to another class type

Comments

Post a Comment