I am trying to use global variables in the default Form.h file in C++ windows form. I have two functions in Form.h file:
private: System::Void Button1_Click(System::Object^ sender, System::EventArgs^ e) {
//Some Code
}
and
private: System::Void Button2_Click(System::Object^ sender, System::EventArgs^ e) {
//Some Code
}
I want to declare globals variables in such a way that both of those above functions can access and modify the variables.
I have already tried making a separate Globals.h file where I have the following code:
namespace Globals { extern bool globalVariable1 = false;
}
In my Form.h file, I have an "#include "Globals.h" declaration. And then I am accessing the global variables in Globals.h and modifying as
Globals::globalVariable1 = true;
This doesn't seem to work.
Aucun commentaire:
Enregistrer un commentaire