C/C++ Compiler (cl.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
C2440
                                             Up Contents Index Back
────────────────────────────────────────────────────────────────────────────
 
     Compiler error C2440
 
     'identifier' : cannot convert from 'type1' to 'type2'
 
     The indicated object could not be converted to the required type.
 
     This error can be caused by converting a user-defined type to
     some other type without supplying a conversion operator.
 
     A conversion operator should be supplied as shown in the following
     example for the class X, which returns an integer. Note that a
     parameter type or a return type is not specified.
 
          class X
          {
          public:
             int j;
          } x;
 
          class Y
          {
          public:
             operator int() { return j; }  // conversion operator
             int j;
          } y;
 
          void main()
          {
               int i;
               i = x;  // error, x cannot be converted to an int
               i = y;  // OK
          }
                                    -♦-