Edit (IMPORTANT): This question was more specific than the question this was marked as a duplicate against. This was asking how to do it with a boolean function. But now I know that it just doesn't work like that. This question shows that
a + b = c
if(c - b == a)
using namespace std;
int a = INT_MAX + 1;
cout << "Overflow" << endl;
cout << "No Overflow" << endl;
unsigned long long
a * a * b
int(pow(base, index) + 0.5)
It depends on what sort of operation you are using and what are the types of the operands.
e.g. if you want to detect an overflow after addition, and both operands are unsigned integers, then an overflow will have occurred if the result is less than the sum of both operands.
bool overflow; if (a+b < a) overflow = true; else overflow = false;
For signed integers, you can refer to the excellent post here