multiple .cpp files for newbies
Thanks Null_Pointer, I turned off the precompiled header stuff and now it does recognize all my .cpp files. Now my new problem is global variables. If I declare a variable before my main function, shouldn''t that variable be seen by all of my functions? I get an ''undeclared identifier'' message when I try to incorporate that variable in the other .cpp files.
Yay!!!
I figured it out myself!! In the other .cpp files, I have to put a line in there like this:
extern myVariable;
Then it worked!!
I figured it out myself!! In the other .cpp files, I have to put a line in there like this:
extern myVariable;
Then it worked!!
no, you shoudn''t do that really
you should have a header file that has
extern MyVariable;
and in the other .cpp files, #include that header file
it has the same effect basically, but its easier to just #include once than type 50 million externs
you should have a header file that has
extern MyVariable;
and in the other .cpp files, #include that header file
it has the same effect basically, but its easier to just #include once than type 50 million externs
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement