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



Relevant Pages

  • Re: help me with copy constructor
    ... i'm sure it completely copys the new object of Str Class in. ... The previous value of pstr is being ... >void Print; ... You need a user-defined copy assignment operator ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Asynchronicity for newbs
    ... void buttonStart_Click ... void class1_StatusUpdate(string str) ... The next bit is that the variables "class1" and "i" act syntactically as local variables but in reality, because they are used within the anonymous method, become "captured" along with the anonymous method. ...
    (microsoft.public.dotnet.languages.csharp)
  • help me understand this char array please....
    ... void strprint(char *str); ... This program when compiled with MSVC++ compiler prints the output as ... 3)AFAIK,when we talk about char arrays,generally the name of the array ...
    (comp.lang.c)
  • Re: RubyToC - Second Question
    ... change the typecast on malloc to be str* ... change long to int for main ... void arr_iterate; ... str * tstarr; ...
    (comp.lang.ruby)
  • Re: Pointers and Arrays in C??
    ... because the array 'str' will no longer exist. ... int main (void) ... You do not have to free the memory pointed to by str before your ... Dynamically allocated memory exists from the point of allocation ...
    (comp.lang.c)