[lug] help

Peter Hutnick peter-lists at hutnick.com
Sun Jun 9 21:57:13 MDT 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Saturday 08 June 2002 07:12 pm, heero yui wrote:

> Could you please tell me how to fix this program?

I'm a bit rusty, so I hope someone will correct me if I am wrong about 
anything.

> Also here is the program...
>
> #include <iostream.h>
> #include <stdio.h>
>
> void findMax(int, int);  // the function declaration (prototype)
>
> int main(int argc, char *argv[])
> {
>
>   int firstnum, secnum;
>
>   cout << "\nEnter a number: ";
>   cin >> firstnum;
>   cout << "Great! Please enter a second number: ";
>   cin >> secnum;
>
>   findMax(firstnum, secnum); // the function is called here
>
>   return 0;
> }

Well, you declared findMax(int, int), but you never implemented it.  That is 
perfectly valid syntacticly, but it doesn't make any sense.  Furthermore, as 
soon as you call findMax it becomes a logic error.

When the linker tries to substitute an offset for the function it fails, since 
there isn't any such function, and therefore no such address.

- -Peter
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9BCOelgog5nbKilkRAvw+AJ48N+XTt6JHsYz7HY5j0yG9tyrtQwCfWIKH
4INqaCJ4imOP0Ldmvnrykz0=
=A5HR
-----END PGP SIGNATURE-----




More information about the LUG mailing list