Share via


編譯器警告 (層級 1) C4928

不合法的 copy-initialization; 已經隱含套用一個以上的使用者定義的轉換

找到多個使用者定義的轉換常式。 編譯器在所有這類常式中執行程式碼。

此警告預設為關閉。 如需詳細資訊,請參閱 預設為關閉的編譯器警告

下列範例會產生 C4928:

// C4928.cpp
// compile with: /W1
#pragma warning(default: 4928)

struct I
{
};

struct I1 : I
{
};

struct I2 : I
{
};

template <class T>
struct Ptr
{
   operator T*()
   {
      return 0;
   }

   Ptr()
   {
   }

   Ptr(I*)
   {
   }
};

int main()
{
   Ptr<I1> p1;
   Ptr<I2> p2 = p1;   // C4928
   // try one of the following two lines to resolve this error
   // Ptr<I2> p2(p1);
   // Ptr<I2> p2 = (I1*) p1;
}