看这个符号所在的类对他的定义!!这个说不准的
你甚至可以重载他 让他做减法呢!
#include <iostream>
using namespace std;
class MyOperator
{
public:
MyOperator();
~MyOperator();
uint32_t operator =( uint32_t InitNumber );
uint32_t operator %( uint32_t DesNumber );
friend ostream& operator << ( ostream& out, MyOperator& MyOut );
private:
uint32_t number;
};
ostream& operator << ( ostream& out, MyOperator& MyOut )
{
out << MyOut.number << endl;
return out;
}
MyOperator::MyOperator()
{
}
MyOperator::~MyOperator()
{
}
uint32_t MyOperator::operator = ( uint32_t InitNumber )
{
number = InitNumber;
return number;
}
uint32_t MyOperator::operator % ( uint32_t DesNumber )
{
number = number - DesNumber;
return number;
}
int main( void )
{
MyOperator a;
a = 10;
cout << a << endl;
cout << a % 5 << endl;
return EXIT_SUCCESS;
}
这个环境下面
a%5就相当于a-5
所以这个说不定的