Hi guys I'm reading a c++ book at the moment and I noticed that in one of the examples the return type is a pointer now what really confuses me is why would you want to return a memory address in the first place I just can't see where or why this would be useful? could someone try explain to me why and where you would use a pointer as a return type with an example would help even more,
thanks in advance
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
usingnamespace std;
int *pint(int* number){
return number;
}
int main()
{
int num = 55;
cout << pint(&num);
}
Because I need an address in memory of the new array. This address can be returned in return operator like in my previous example, or as a parameter value: