Partilhar via


Aviso do compilador (nível 1) C4927

conversão inválida; mais de uma conversão definida pelo usuário foi aplicada implicitamente

Mais de uma conversão definida pelo usuário é aplicada implicitamente a um único valor – o compilador não encontrou uma conversão explícita, mas encontrou uma conversão, que ela usou.

A amostra a seguir gera C4927:

// C4927.cpp
// compile with: /W1
struct B
{
   operator int ()
   {
      return 0;
   }
};

struct A
{
   A(int i)
   {
   }

   /*
   // uncomment this constructor to resolve
   A(B b)
   {
   }
   */
};

A f1( B& b)
{
   return A(b);
}

B& f2( B& b)
{
   return b;
}

A f()
{
   B b;
   return A(b);   // ok
   return f1(b);  // ok
   return b;      // C4927
   return B(b);   // C4927
   return f2(b);  // C4927
}

int main()
{
   B b;
   A a = b;
   A a2(b);
}