When I want to implement a function in C++ , if it matters to receive the int array in the following cases?
void fn1(int []a) {
a[0] = 1;
}
void fn2(int a[]) {
a[0] = 1;
}
When I want to implement a function in C++ , if it matters to receive the int array in the following cases?
void fn1(int []a) {
a[0] = 1;
}
void fn2(int a[]) {
a[0] = 1;
}
In Java, there is no semantic difference.
In C++, the first syntax is invalid.
Well, the question is not clear.. Whether to receive the int array or not, it depends on the logics of your method. In Java it is better to write a[], but you can write either way.
Also, look over here - pass array to method Java
In Java,the declaration is same...
but in C++,the fn1()
declaration need to be different