Below is the code from the C++ basics course, Unit 4 on arrays and pointers
#include <iostream>
using namespace std;
void increment(int &number) {
cout << "The address of number is: " << &number << endl;
number++;
cout << "Now the value of number is: " << number << endl;
}
int main() {
// Declare the number
int number = 42;
// Print the number's value
cout << " The value of number is: " << number << " and the address is: " << &number << endl;
return 0;
}
In below line, we are passing the integer number to the function as a parameter,.
// Call the function increment
increment(number);
In below line, the function is defined such that it accepts the address of an integer as a parameter.
void increment(int &number)
But in the program , when we are calling the function, we are passing an integer as a parameter instead of address,like say, increment(&number);
can i know why this is?