You should declare the function before you use it
登录 | 论坛导航 -> 华新鲜事 -> 求学狮城 | 本帖共有 3 楼,分 1 页, 当前显示第 1 页 : 本帖树形列表 : 刷新 : 返回上一页
<<始页  [1]  末页>>
作者:香陵居士 (等级:16 - 好恐怖呀,发帖:22662) 发表:2003-05-13 19:18:51  楼主  关注此帖
A C++ problem about arrayI 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 void main() { int max_element(); int n, a[10]; int max; for(n=0; n>a[n]; max=max_element(a, 10); cout (more...)
You should declare the function before you use it
main() is an exception. All the other functions need to be declared before use. Just put your function prototype at the beginning of the program.

BTW: It's better to use <iostream> than <iostream.h>
最新推出专栏《倾听索罗斯》 欢迎大家前来捧场!

Yeah!
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
作者:香陵居士 (等级:16 - 好恐怖呀,发帖:22662) 发表:2003-05-15 05:28:21  2楼
is it not backward compatible de mah?not very sure, please teach me more :)
It seems that you are really new to C/C++
Functions need to be declared before use, this is the basic rule for C/C++.
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
作者:香陵居士 (等级:16 - 好恐怖呀,发帖:22662) 发表:2003-05-16 05:55:39  3楼
只要把下面的函数体整个放到main前面就行了。不一定非要declare。
也算是declare了
函数定义前面也给出了prototype的啊!

一般的做法还是先declare,后implement。特别是C++。
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
论坛导航 -> 华新鲜事 -> 求学狮城 | 返回上一页 | 本主题共有 3 篇文章,分 1 页, 当前显示第 1 页 | 回到顶部
<<始页  [1]  末页>>

请登录后回复:帐号   密码