accessing elements of header file in other windows
-
Hi,
That's rather a C++ question. Why do you want to do it like that ? Global variables like that should rather be avoided as much as possible.
-
@nasir
Ignoring the question of whether it is good design or not, I would have expected the line you show in your "main window" file should readint Nodecount = 8;
. Make sure that does not change the error? If not: it would be an error to meet such a line more than once in a file, are you sure you do not have another line in your main window file which defines the variable?Also, in your main source file: are you including the "random" header file before the line where you try to define the variable?
It's also best when you have a compile error to show the actual error message together with the actual line of source the error message mentions.
-
@nasir
It has no effect on what is in the header file one way or the other. It is indeed defining & setting the initial value of the variable declared in the header file. You can indeed access that variable from any other file where you include that header file.