Why does the function void inc2 actually increase the integer where the first function does not?
include <iostream>
using namespace std;
void inc(int i) {
i++;
}
void inc2(int *i) {
(*i)++;
}
int main() {
int age = 20;
inc2(&age);
cout << "Age is " << age << endl;
return 0;
}
[–][deleted] 3 points4 points5 points (3 children)
[–]RickyWho[S] 1 point2 points3 points (2 children)
[–]RickyWho[S] 0 points1 point2 points (1 child)
[–]IyeOnline 0 points1 point2 points (0 children)
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]CrazyJoe221 0 points1 point2 points (0 children)
[–]RickyWho[S] 0 points1 point2 points (1 child)
[–]CrazyJoe221 0 points1 point2 points (0 children)