If Form1
is the one that instantiates packet_class
, just pass it as a parameter to the constructor.
ref class packet_class
{
SerialPort^ serial;
packet_class(SerialPort^ serial)
{
this->serial = serial;
data_to_send="SEND ABC";
}
};
// Somewhere in Form1....
packet_class packet = gcnew packet_class(this->serialPort1);