• Advertisement

Archived

This topic is now archived and is closed to further replies.

extern Classes

This topic is 5555 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Supose i have a class like this : class foo { AddLine(Char *blab); }; This class is defined in first.cpp as foo myfoo; Now, i would like to use this class in another file in the same project, in second.cpp for example. myfoo.AddLine("foo again"); so, i declare the variable as external in this second.cpp as extern myfoo; The problem now is that when compiling i have this error : error C2228: left of ''.AddLine'' must have class/struct/union type Looks like he doens''t recognize the funtions inside the class.. How can i do this ? thanks, Bruno

Share this post


Link to post
Share on other sites
Advertisement
Doens't work either.., , like that i get this error :

error C2146: syntax error : missing ';' before identifier 'foo'

[edit]
It's working.., i forgot to include the header file
thanks
[\edit]

[edited by - Bruno on December 7, 2002 8:36:06 AM]

Share this post


Link to post
Share on other sites
Declare the class in a header; #include this header in each file where you need to use the class. Read this while you''re at it.

Share this post


Link to post
Share on other sites

  • Advertisement