Compiler Error C2831
'operator operator' cannot have default parameters
Only three operators can have default parameters:
Assignment =
Left parenthesis (
The following sample generates C2831:
// C2831.cpp
// compile with: /c
#define BINOP <=
class A {
public:
int i;
int operator BINOP(int x = 1) { // C2831
// try the following line instead
// int operator BINOP(int x) {
return i+x;
}
};
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for