'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. If you’ve encountered this error on code which compiled with an earlier version of Visual C++, please read Technote: Improved Conformance to ANSI C++ for more information.
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