difference between
(int a[ ]) and (int &a) and (int *a)
Function arguement
int a[] is to initialize an array(when array size is not mentioned). In such a case, you have to initialize the array in the same line where you declare it.
Example: int a[]={1,2,3,4}
int &a is a reference variable. It is used to make a copy of another variable.
Example:
int x=10;
int &y=x;//Initializing a reference variable. Variable y is another name for x. So whatever changes you make in x, it will be reflected in y.
int *a is a pointer variable(used to store address).
In terms of function defination:
func(int a[]) and func(int *a) means the same thing. Both the way can be used if array is passed .
func(int &a) means an integer is passed to the function by reference. So whatever changes made to this variable inside the function will be reflected back in the main (from where the function was called).
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.