A C++ problem about array
所在版块:求学狮城 发贴时间:2003-05-13 16:09

用户信息
复制本帖HTML代码
高亮: 今天贴 X 昨天贴 X 前天贴 X 
I am a beginner of C++ programming. When I am learning the array, I copied a program from a book and cannot be executed. I don't know what is wrong? Please help me!!!


#include<iostream.h>
void main()
{
int max_element();
int n, a[10];
int max;
for(n=0; n<10; n ++)
cin>>a[n];
max=max_element(a, 10);
cout<<max;
}
int array[], size;
int max_element(array,size)
{
int temp, j;
temp = array[0];
for(j=0; j<size; j++)
if(temp<array[j]) temp=array[j];
return temp;
}



The errors are
'max_element' : function does not take 2 parameters
<Unknown>' : function-style initializer appears to be a function definition
.
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!

Put your OWN COOL signature here!
 相关帖子 我要回复↙ ↗回到正文
A C++ problem about array joyce   (625 bytes , 418reads )
This program is not pure C++ Flying   (0 bytes , 150reads )
You should declare the function before you use it 香陵居士   (202 bytes , 182reads )
只要把下面的函数体整个放到main前面就行了。 Livecn   (19 bytes , 178reads )
也算是declare了 香陵居士   (86 bytes , 170reads )
is it not backward compatible de mah? MrDJay   (38 bytes , 224reads )
It seems that you are really new to C/C++ 香陵居士   (75 bytes , 175reads )
thanks :$ MrDJay   (23 bytes , 160reads )
come in>> 我行故我   (490 bytes , 192reads )
what is this for? MrDJay   (19 bytes , 202reads )
guess it is the problem MrDJay   (0 bytes , 149reads )