- 论坛徽章:
- 0
|
最近看书自学到数组这章..书上在打印数组的时候都是直接打印数组,然后我结合前面学的 想把数组的打印放到函数里面 “按值传递” 可是出现错误!
#include <iostream>
using namespace std;
void showArray(int souArray[5]){
int souArray[5] ; //提示语法错误
int temp;
for(temp=0;temp<=4;temp++){
cout<<souArray[ temp ]<<"\n";
}//END FOR
};//END SHOWARRAY
int main(){
int myArray[5] = {36,56,32,12,10};
showArray(int myArray[5]); //提示语法错误
/*
for (i=0;i<=4;i++){
cout<<myArray[ i ]<<"\n";
}//END FOR
*/
}//END MAIN
编译的时候错误提示
g++ -o test array.cpp
array.cpp: In function `void showArray(int*)':
array.cpp:8: declaration of `souArray' shadows a parameter
array.cpp: In function `int main()':
array.cpp:23: syntax error before `[' token
array.cpp:31:12: warning: no newline at end of file
我按引入传入也不行 帮我整整 谢了 ! |
|