Today, i receive email from one of forum asking about why we are using a pointer.
As long as I know we can use a pointer for making dynamic array. We can’t use variable without pointer to make a dynamic array. As an example:
We can’t do:
But we have to do:
size = 10;
int *i=new int [size];
The other reason is if we want to make a function, which one of input parameter is output, we can use pointer. But in my experience it’s better if we use reference. For example
void add(int a, int b, int &c)