Skip to main content
gamedev.net
🔒 Locked

extern Classes

Started by Bruno Dec 7, 2002 at 6:57 AM 2 replies 150+ views
Original Post
Bruno
Bruno
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
Fruny
Fruny
extern foo myfoo;

Plus your function needs to be public.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Bruno
Bruno
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]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.