Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/162.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在C+中的MFC形式中访问全局var+; 我在Windows窗体C++项目中实现了以下几点 template<class T> class MyQueue { T *m_data; int m_numElements; public: MyQueue() : m_data(NULL), m_numElements(0) { } ..... code ..... }; MyQueue<char> logData; // I need to acces it from Form1.h [STAThreadAttribute] int main(array<System::String ^> ^args) { // Enabling Windows XP visual effects before any controls are created Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); // Create the main window and run it Application::Run(gcnew Form1()); return 0; } 模板类MyQueue { T*m_数据; 国际货币基金组织; 公众: MyQueue():m_数据(NULL),m_numElements(0){} ……代码。。。。。 }; MyQueue日志数据;//我需要从Form1.h访问它 [属性] int main(数组^args) { //在创建任何控件之前启用Windows XP视觉效果 Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); //创建主窗口并运行它 应用程序::运行(gcnewform1()); 返回0; }_C++_Variables_Visual C++_Global Variables - Fatal编程技术网

如何在C+中的MFC形式中访问全局var+; 我在Windows窗体C++项目中实现了以下几点 template<class T> class MyQueue { T *m_data; int m_numElements; public: MyQueue() : m_data(NULL), m_numElements(0) { } ..... code ..... }; MyQueue<char> logData; // I need to acces it from Form1.h [STAThreadAttribute] int main(array<System::String ^> ^args) { // Enabling Windows XP visual effects before any controls are created Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); // Create the main window and run it Application::Run(gcnew Form1()); return 0; } 模板类MyQueue { T*m_数据; 国际货币基金组织; 公众: MyQueue():m_数据(NULL),m_numElements(0){} ……代码。。。。。 }; MyQueue日志数据;//我需要从Form1.h访问它 [属性] int main(数组^args) { //在创建任何控件之前启用Windows XP视觉效果 Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); //创建主窗口并运行它 应用程序::运行(gcnewform1()); 返回0; }

如何在C+中的MFC形式中访问全局var+; 我在Windows窗体C++项目中实现了以下几点 template<class T> class MyQueue { T *m_data; int m_numElements; public: MyQueue() : m_data(NULL), m_numElements(0) { } ..... code ..... }; MyQueue<char> logData; // I need to acces it from Form1.h [STAThreadAttribute] int main(array<System::String ^> ^args) { // Enabling Windows XP visual effects before any controls are created Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); // Create the main window and run it Application::Run(gcnew Form1()); return 0; } 模板类MyQueue { T*m_数据; 国际货币基金组织; 公众: MyQueue():m_数据(NULL),m_numElements(0){} ……代码。。。。。 }; MyQueue日志数据;//我需要从Form1.h访问它 [属性] int main(数组^args) { //在创建任何控件之前启用Windows XP视觉效果 Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); //创建主窗口并运行它 应用程序::运行(gcnewform1()); 返回0; },c++,variables,visual-c++,global-variables,C++,Variables,Visual C++,Global Variables,我想在Form1.h中访问它 在 private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { ??? MyQueue<char> logData; // I need to acces it } private:System::Void Form1\u Load(System::Object^sender,System::EventArgs^e) { ???MyQueu

我想在Form1.h中访问它 在

private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) 
{
  ??? MyQueue<char> logData; // I need to acces it 
}
private:System::Void Form1\u Load(System::Object^sender,System::EventArgs^e)
{
???MyQueue logData;//我需要访问它
}

有什么线索吗?

您可以声明
日志数据
静态。访问原始数据成员通常被认为是不好的做法,因此您可能还希望提供一种静态方法来将字符放入队列中。这是一个关于C++中静态成员的教程。

表单1
类之外,提供

extern MyQueue<char> logData;

关于
externMyQueue日志数据(在全局范围内)在
格式1.h
?@πάντα中ῥεῖ 你介意回答一个问题吗?对不起,我是C++的新手。你介意提供一个更扩展的答案吗?可能是因为
模板类MyQueue
是在
main
cpp类中实现的。请告诉我如何正确地完成它。@dimi请看,关于
MyQueue
please的实现。你可能做错了。
private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
    logData.pop(); // Access it 
}