Hello ladies and gents,
Ive been reading about when you have a very large program, that it is advisable to divide this into several modules. Ive tried this out with an example of two separate modules that where given as examples and managed to get two .cpp modules into the Source files of the workspace of one of those.
Examples:
#include <iostream>
using namespace std;
extern int n;
void f(int i), g();
int main()
{
cout<<"Previous n = "<< n <<" (module 1)\n";
f(8);
g();
cout<<"Press any key to continue!\n";
return 0;
}
#include <iostream>
using namespace std;
int n = 100;
static int m = 7;
void f(int i)
{
n += i + m;
}
void g()
{
cout<<"After raising it with 8 + 7 (in module 2):\n";
cout<<"n = "<< n <<endl;
}
I'm using VC++6.0 as compiler on XP Pro if you need to know.
I did it following this path: Project --> Add Project --> Files --> Added the necessary . cpp file!
Now, the question is, is this what is called linking?
The reason I ask is because in the book, after they talk about the 'linker', they talk about the following:
It's also possible in this compiler (the author also used VC++6.00 compiler) to make use of a 'Project' in wich the two named files would be incorporated (C1 module1.cpp module2.cpp). These executable files wich are created by executing this command 'Project' would have the name module1.exe. If we start the program by entering this name (don't have a clue where this would be entered ?? ) then the output would be the following:
Previous: n = 100 (module 1)
After raising it with 8 + 7 (in module 2):
n = 115
What is the difference between using the 'linker' and this so called 'Project' :?: