I am trying to take the text input from the "Form1"(form.h) and pass it to the .cpp file(form.cpp). In form.h
public ref class Form1 : public System::Windows::Forms::Form
{
...
#pragma endregion
public: String^ username;
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
username = textBox1->Text;
//i want this variable in the .cpp file
}
Since you've created a class, and are assigning a value to a member variable, it's already going to be in your .cpp
file, and can be referenced as long as you remember to #include "form.h"
in it.
Note that this isn't necessarily the best practice, though. It's often considered prudent to put all implementation details in your .cpp
file - in part because it helps avoid confusing situations like these.