摘要:
在Qt中使用全局变量的实例1.首先需要在一个头文件中对全局了变量使用exern方法进行定义。//g.h extern char *testStr;2.只能在cpp文件中对其是实例化,并且实例化只能在函数的外部进行。建议在包含main函数的cpp文件中进行实例化,这样可以确保在其他文件中使用时,它已经被实例化。//a.h #include "g.h" char *testStr="hello world"; void main() { cout<<testStr<<endl; testStr="hello China&qu 阅读全文
posted @ 2013-01-28 11:33
夜&枫
阅读(2354)
评论(0)
推荐(0)
浙公网安备 33010602011771号