For uniary operators, there is the pre-increment (++i) and post-increment (i++). For pre-increment, the value to be incremented will added before an operation. For example:
#include <iostream>
using namespace std;
void main()
{
int i = 0;
cout << ++i;
}
In this case, the output would be 1. The variable 'i' was incremented by the value of 1 before any other operations i.e. 'cout << ++i'.
Now, if we did the post-increment in the same function:
#include <iostream>
using namespace std;
void main()
{
int i = 0;
cout << i++;
}
The output would only be 0. This is because the increment would happen after the operation. But since you want to know about passing them in as parameters, this is how it will go:
#include <iostream>
using namespace std;
// Function Prototypes
void PrintNumbers(int, int);
void main()
{
int a = 0, b = 0;
PrintNumbers(++a, b++);
}
void PrintNumbers(int a, int b)
{
cout << "First number: " << a << endl;
cout << "Second number: " << b << endl;
}
When passing in those variables as parameters, the output would be:
First number: 1
Second number: 0
I hope this helps!!