I'm learning CPP and I came through this piece of code.
#include <iostream>
using namespace std;
 
int main() {
 
    int a=1;
      cout<< ++a + a++ ;
}
When I run this the answer is 5.
I looked through the operator precedence and found that postfix has higher precedence than prefix. So according to me first the postfix should be evaluated after that the prefix. a++ will just substitute 1 and increment a after that , then ++a will increment a and place 3 there which should result in 4. Where am I going wrong.
 
    