Can we define our own operator in c++?
I need to define a%%b as (a%b+b)%b because sometimes a%b gives a negative value(-239%5=-4), and I want the positive reminder. So if a%b is negative, add b to a%b and return the value. This can be simply done using (a%b+b)%b. I tried
#define a%%b (a%b+b)%b
but it is giving error. We can do this by using a function
int mod(int a, int b){
return (a%b+b)%b;
}
but I want to do this by defining as I do for a 'for' loop
#define f(i,a,b) for(int i=a;i<b;i++)
please suggest me a way to define a%%b as (a%b+b)%b.