C ++, when declaring a struct as a global variable, later I can not access it from an object (class) ... The development environment consists of three files:
-
the 1st file contains the main pgm, so the variable is defined:
struct stXXX { TIMESTAMP_STRUCT timestamp; // Horario de generación del registro en tabla VarProceso double contador; // Cantidad de bolas ingresadas float diametro; // Diametro de bolas ingresadas } stXXX;
-
the 2nd file is a header for the declaration of the class.
- the 3rd file contains the code (c ++) of the object that is invoked from the 1st file.
The struct is declared before the main()
in the 1st file, if I use it in the main pgm, it does not generate any errors.
The compiler warns me that the "identifier stXXX is undefined"
when I use it in the 3rd file.
I manage the project with Microsoft Visual Studio Community 2015
My questions are:
- a.- Can I do what I'm doing?
- b.- How should I declare it to be visible from the code where the object is programmed (3rd file)? or
- c.- How does the reference from the 3rd file?