X
xiaoxiaoyang
Hi,
I have a variable, previously was a constant, and defined in a header
file, e.g., A.h, and then now I would like to change this variable as
can be specified from a parameter file, such as B.cpp. like below:
in A.h before change, I have
static int constant CONST_X = 100;
Now I would like to be specified in B.cpp, that can read the variable
value from a file.
in B.cpp, I have:
static int X = 300; // can read from a file, or change in B.cpp.
I achieve the modification, in A.h, I did the below modification:
static int const CONST_X = class B::X;
or static int const CONST_X = B::X;
But I got error of "B has not been declared" when compiling.
or class B;
static int const CONST_X = B::X.
But I got error of incomplete type "B" used in nested named specified.
I think a stupid method is to comment out the line "static int const
CONST_C=100" in the original A.h, and replaced everywhere in every
class which uses CONST_C with B::X in the code (and define X in B.cpp
as above), but I think this method is so inefficient, and they most be
some method that allow me to only replace the CONST_X by B::X in the
A.h only, like I was trying to do but unsucceeded yet.
Can someone tell me how to solve this problem?
Thank you very much for the help.
Xiaoxiao
I have a variable, previously was a constant, and defined in a header
file, e.g., A.h, and then now I would like to change this variable as
can be specified from a parameter file, such as B.cpp. like below:
in A.h before change, I have
static int constant CONST_X = 100;
Now I would like to be specified in B.cpp, that can read the variable
value from a file.
in B.cpp, I have:
static int X = 300; // can read from a file, or change in B.cpp.
I achieve the modification, in A.h, I did the below modification:
static int const CONST_X = class B::X;
or static int const CONST_X = B::X;
But I got error of "B has not been declared" when compiling.
or class B;
static int const CONST_X = B::X.
But I got error of incomplete type "B" used in nested named specified.
I think a stupid method is to comment out the line "static int const
CONST_C=100" in the original A.h, and replaced everywhere in every
class which uses CONST_C with B::X in the code (and define X in B.cpp
as above), but I think this method is so inefficient, and they most be
some method that allow me to only replace the CONST_X by B::X in the
A.h only, like I was trying to do but unsucceeded yet.
Can someone tell me how to solve this problem?
Thank you very much for the help.
Xiaoxiao