本文介绍了c ++如何初始化静态CStringArray?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我不会在类中初始化静态CStringArray: 班级:(* h) i wont to initialize static CStringArray in class like this:the class: (*h)class x { static CStringArray imagesFilesNames;}; cpp *: cpp* :CStringArray Shape::imagesFilesNames(setImagesFilesName());CStringArray setImagesFilesName(){CString path=getCurrentPath(L"images");CStringArray tmp;ListFolderContents(path,tmp);return tmp;}CString getCurrentPath(CString folderNameCategory){///to someting}void ListFolderContents(LPCTSTR lpszFolderPath, CStringArray& fileListing){ ///to someting} 问题: 未找到functios的身份: -setImagesFilesName() -CString getCurrentPath(CString folderNameCategory) -void ListFolderContents(LPCTSTR lpszFolderPath,CStringArray& fileListing) i托盘使这些功能上课功能 它仍然不起作用 请帮忙!!! :) 推荐答案 使这些函数成为类的成员函数(正如您已经尝试过的那样),然后在类的构造函数中初始化。当为每个对象调用构造函数时,应该包含一个额外的静态bool成员变量,在该变量中可以存储已经初始化字符串数组的事实。Make these functions member functions of your class (as you have already tried) and then initialize in the constructor of your class. As the constructor is called for every object, you should include an additional static bool member variable, in which you can store the fact that you already have initialized your string array. 这篇关于c ++如何初始化静态CStringArray?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-27 16:05