नोट
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप साइन इन करने या निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
binary 'operator' : 'type*' does not define this operator or a conversion to a type acceptable to the predefined operator
Remarks
To use the operator, you must overload it for the specified type or define a conversion to a type for which the operator is defined.
Examples
The following example generates C2676.
// C2676.cpp
// C2676 expected
struct C {
C();
} c;
struct D {
D();
D operator >>( C& ){return * new D;}
D operator <<( C& ){return * new D;}
} d;
struct E {
// operator int();
};
int main() {
d >> c;
d << c;
E e1, e2;
e1 == e2; // uncomment operator int in class E, then
// it is OK even though neither E::operator==(E) nor
// operator==(E, E) defined. Uses the conversion to int
// and then the builtin-operator==(int, int)
}
C2676 can also occur if you attempt to do pointer arithmetic on the this pointer of a reference type.
The this pointer is of type handle in a reference type. For more information, see Semantics of the this pointer.
The following example generates C2676.
// C2676_a.cpp
// compile with: /clr
using namespace System;
ref struct A {
property Double default[Double] {
Double get(Double data) {
return data*data;
}
}
A() {
Console::WriteLine("{0}", this + 3.3); // C2676
Console::WriteLine("{0}", this[3.3]); // OK
}
};
int main() {
A ^ mya = gcnew A();
}