Re: implicit declaration of function error

From: Martijn Lievaart (m_at_remove.this.part.rtij.nl)
Date: 01/01/04


Date: Thu, 01 Jan 2004 12:43:12 +0100

On Thu, 01 Jan 2004 08:44:18 +0000, Jason wrote:

> Hi,
>
> Im running windows xp pro and compiling using dev c++ 4. I have the
> following situation:
>
> #include <iostream>
> #include <string>
> using namespace std;
>
> int main() {
> string str;
> func(str);
> }
>
> void func(string str) {
> //do stuff, call some other classes member functions etc
> func2(str);
> }
>
> void func2(string str) {
> //do more stuff
> }
>
> It says 2 errors occur with the following output:
>
> 7 errormain.cpp
> implicit declaration of function `int func(...)'
> 7 errormain.cpp
> warning: cannot pass objects of type `string' through `...'
> 12 errormain.cpp
> implicit declaration of function `int func2(...)'
> 12 errormain.cpp
> warning: cannot pass objects of type `string' through `...'
>
> What am I doing wrong???

Forward declare (aka prototype) your functions. Add the following after
the using namespace std;

void func(string str);
void func2(string str);

HTH,
M4