+ 1
They have different uses based on context: & can be a bitwise AND, and * can mean multiply, however I assume you mean in the context of pointers? int i = 5; increment("&i) The above call to increment(), send the address of the integer variable i, as the second argument. C and C++ functions can't change the values of arguments sent to them, but they can change the value of an item, if that item's memory address is passed instead. void increment(int* a) { // The *a here means 'work on the value // at memory address 'a' (*a)++ } int i = 5; increment(&i); The above code will increment the value stored in i. void no_increment(g) { g++; } i = 5; no_increment(i) i will not be changed.
24th Apr 2018, 10:02 AM
Emma