Mail Archives: djgpp/2000/10/03/01:48:44
On Mon, 2 Oct 2000 17:48:46 -0400, "Daniel"
<cdnhermit DOT msn AT attcanada DOT net> wrote in comp.os.msdos.djgpp:
> Hello, I have a simple application that does not compile because of this
> function:
> print_result(a, x, power_for(a, x));
>
> which cause the following error:
> app.cc(23) Error: Implicit declaration of function 'int power_for(...)'
>
> Here is part of the code:
> int main() {
> int x;
> double a;
>
> get_input(a, x);
> print_result(a, x, power_for(a, x));
> ......
>
> The function does return a double [ double power_for(double a, int x){ ]
> of course, the function power_for(a, x) is define in another file
>
> Is there a way to deal with that kind of problem? Please note that it
> compiles without any error with Borland 5.02.
>
> Thank you
> Daniel
In C++ it is illegal to call a function without a prototype in scope.
This is different than it is from C, where it is legal but only if the
function meets certain requirements, one of which is that the return
type must be int.
So in both C and C++, you must have a prototype in scope to call a
function that returns anything other than int.
Just add a prototype to the source file that calls the function,
before the function call:
double power_for(double, int);
Jack Klein
--
Home: http://jackklein.home.att.net
- Raw text -