Compiler Error C2446

'operator' : no conversion from 'type1' to 'type2'

The compiler is unable to convert type1 to type2. Normally the compiler is able to convert from one type to another, but sometimes a conversion does not make sense because it would violate the semantics of C or C++. 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.

The example below illustrates two conversion problems:

  1. Converting an int to a pointer to char has no meaning and is not allowed.

  2. Converting a pointer to a const object to a pointer to a non-const object is not allowed. If you could obtain such a pointer, you could modify the const object through it, violating the sematics of const.
    int i;
    char *p;
    int *j;
    const int *cj;
    
    void main()
    {
       p = i;  // ERROR #1: conversion has no meaning
       j = cj; // ERROR #2: pointer to const obj
    }