編譯器警告 (層級 3) C4522
'class' :指定多個指派運算符
類別具有單一類型的多個指派運算元。 此警告為參考;建構函式可在您的程式中呼叫。
使用警告 pragma 來隱藏此警告。
範例
下列範例會產生 C4522。
// C4522.cpp
// compile with: /EHsc /W3
#include <iostream>
using namespace std;
class A {
public:
A& operator=( A & o ) { cout << "A&" << endl; return *this; }
A& operator=( const A &co ) { cout << "const A&" << endl; return *this; } // C4522
};
int main() {
A o1, o2;
o2 = o1;
const A o3;
o1 = o3;
}