2

I'm working on a UI for my project and I am using C++.

I have: 2 Windows Forms - Form1.h, Form2.h

1 Header file - Header.h where I have my common includes, functions and global variables that the two need to share.

I tried declaring the global variables as normal static variables and it compiled fine but the two forms aren't really sharing the global.

After research I found ref classes:

public ref class Global     {   
public: static int Var1;    
public: static double Var2;     
public: std::string fileName;   
public: static cv::Mat frame;   
};

This works fine for the int and double variable but refuses to compile and an class is involved (ie. std:: and cv::). Is there anything I can do to allow a non-managed class in a managed one?

I read that we can use pointers to get around it (public std::string * fileName;) but I can't figure out what to do after this.

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
myName
  • 41
  • 4

0 Answers0