Dear all, first of all, thanks for your replies. Let me clarify what I intend to do:
In the source directory of my code, among many other files, I have A.cxx and B.cxx (with headers in header file). There is no "friend"ship between them. In the file B.cxx, I wish to use a set of variables that have already been calculated in A.cxx.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
A header: (A.h)
class A
{
public:
... ...
... ...
private:
bool muzdir;
int nplane;
double chi_sqr;
.... ....
};
A source (A.cxx)
#include "A.h"
#include <... ...>
#include <vector>
... ...
if (... ...)
muzdir = true;
else
muzdir =false;
... ...
for (... ...) { chi_sqr += ...}
... ...
etc.
|
I want to use these variables (muzdir, chi_sqr etc.) in B.cxx. First, I tried to declare these variables as public in A.h; then, including "A.h" among the dependencies, I tried to access them directly from B.cxx.
That did not work: compiler said that this variable was not declared in the scope.
Hence, I thought of Setting these numbers in an intermediate file "C": Set() from A, Get() from B. The class C was not declared as a "friend" class to either A or B. I tried to access the variables as described before. But that, as said before, is giving the value initialized in the constructor of C. Please let me know if I am clear. Thanks for your time,
-regards,
Kolahal