I am creating two 2D arrays in one file, say readbundle.cpp. They are quite huge in dimension, as they actually 3D points created from an image, after some heavy mathematics.
Now, how can I use the values from here, in another file, resectioning.cpp? I know this uses the concept of oops and classes. But if you can just temme the probable syntax and how to use them, it would be really helpful. Please help me here. Thanks in advance. I have searched in google, but since I am new to this,I am not sure what am I looking at or where to look. My apologies if you feel this is very rudimentary.
The code is in c++.
They are 2 different files totally. I haven't made them a same program or created any class. This is what I want to know. How to connect them, and how to use the values from one in another.
Suppose X[i][j] is just normally created and defined in readbundle.cpp and after compiling and executing it, I have certain values in X[i][j].
Now I want to use this X[i][j] in the program, resectioning.cpp, which I am compiling separately. I haven't defined any class, or any oops. Please help me how can I achieve this. These two programs aren't connected as of now. They are just normal programs. I know I have to do something public and call the variable somehow. But I just dunno the right way of doing it. Please correct me if am wrong as well.
Edit
suppose the readbundle.cpp is as follows
#include ...
.
.
vector<vector<int> >X3D;(declared global)
.
.
and the resect.cpp is as follows
#include ....
.
.
.
extern vector<vector<int> >X3D //will the values be reflected here?
//the values changed in *readbundle.cpp*
int main()
{
cout<<X3D[0][0]<<endl;
}
From the answers, I hope I understood the concept of extern correct. Please help me if am wrong.
NOTE Will I get the same values X3D from the previous file? Am getting an error in this case. How can I achieve the functionality am looking for?