I'm looking for possible help or tutorials about using a
Multi File Source Code, the whole program uses each other's
variable so there isn't such thing as an alone class (that's easy
to seperate)
I'm looking for possible help or tutorials about using a
Multi File Source Code, the whole program uses each other's
variable so there isn't such thing as an alone class (that's easy
to seperate)
Do you mean a procedural C style design? Consider #include.
Kuphryn
I know how to include and link etc.
I want to know how to combine different c++ sources,
with the declarations in the headers,
And how to connect them, i know how to do that as well
but only if they don't use each other's variable, that's
what i want to accomplish
I think i´ve seen #include in some source codes. Consider you have three separate files: main.cpp vars.cpp and functs.cpp. In main.cpp you have the main() function, in vars.cpp you have all the variables and in functs.cpp you have all the other functions you need for your program. You could write this at the heading of the main.cpp file:
I think that should work.Code:#include functs.cpp //file with the functions #include vars.cpp //file with the variables main() { // the rest of the code here... }
Just the thoughts of a C++ newbie...
That's not the way you should use CPP files, ive intregrated them
into my project and thus linking it together with other sources,
But i just need a tutorial on using multi file sources, it arent just
peaces of code that i 'add' in my source they all cooperate
I'm confusing, i'l explain more clearly,
The actual problem is that the header of CLASS1 includes
all the global variables and the MAIN header includes them
as well and there's problem
error LNK2005: "" (?error LNK2005: "float * " (?@@3PAMA) already defined in Main.obj@@3_NA)
already defined in Main.obj
What is your design? Post an example of what you want to implement.
Kuphryn
Oke, how can i get CLASS1.cpp to use MAIN.cpp variables?
Class1 have no knowledge of local variables in main by design.
Kuphryn
New explanation!!!
I have:
Monkey.ccp
// includes monkey.h and main.h
Monkey.h
// declarations od the class monkey
Main.ccp
// has main, includes main.h and monkey.h
Main.h
// Containts global variables
This results is
error LNK2005: "int bla@@3HA) already defined in Main.obj
So i need to use the variables in main.h in main.cpp and
monkey.cpp, however if main.cpp is compiled main.obj contains these, and if monkey.cpp compiles, it errors up
saying that main.obj alerady has these! how can i get monkey.cpp to use main.cpp's variable's?
Figured it out already ,
Thx for the reply's anyhow
Close me
>>Figured it out already
I take it you found the extern keyword then!
Also, you shouldn't #include source files (.cpp), only header files (.h).
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
I know i know, i dint suggested that, and indeed it was extern