如何在mfc项目中声明一个全局变量 [英] how to declare a global variable in mfc project

查看:104
本文介绍了如何在mfc项目中声明一个全局变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个应该是全局的矢量,这样我就可以在项目的任何地方访问它。

感谢Advanced。

解决方案

< blockquote>听起来真的很糟糕。它会让你有一天感到麻烦,所以你会伤害自己。



如果你想在膝盖上开枪:

一(1)个标题或类标题中的


  extern  MyVector theGlobal; 




一(1)个cpp文件中的
或最好的类实现

 MyVector theGlobal; 





请阅读 MVC架构,以增强您的知识。 (感谢答案)


I want a vector that should be global, so that i can access it anywhere in my project.
thanks in Advanced.

解决方案

It really sounds like poor design. It will make you trouble some day, so you harm yourself.

If you want to shot you in the knee:

in one (1) header or the class header

extern MyVector theGlobal;



in one (1) cpp file or best the class implementation

MyVector theGlobal;



Please read about MVC architecture to enhance your knowledge. (As thank for the answer)


这篇关于如何在mfc项目中声明一个全局变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆