C/C++ Compiler (cl.hlp) (Table of Contents; Topic list)
C2434
                                             Up Contents Index Back
────────────────────────────────────────────────────────────────────────────
 
     Compiler error C2434
 
     'identifier' : cannot convert default argument from 'type1' to
     'type2'
 
     The indicated default parameter could not be converted into the
     type specified in the function's formal parameter list.
 
     This error can be caused by an incorrect function prototype or by
     using the wrong value for a default parameter. To use the indicated
     default parameter, you should define a conversion operator or a
     constructor that takes a single parameter of the same type as the
     specified default parameter.
 
     The following is an example of this error. Note that if the
     conversion operator in A is supplied, then there is no error.
 
          class A
          {
          public:
             int i;
          } a;
 
          class B
          {
          public:
             operator int() { return i; }    // conversion operator
             int i;
          } b;
 
          void func1( int j = a ) {}  // error, can't convert a to int
          void func2( int j = b ) {}  // OK
                                    -♦-