Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i wont to initialize static CStringArray in class like this:

the class: (*h)
class x 
{
 static  CStringArray imagesFilesNames;
};


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
}


the problems:


identtifier no found to the functios:
-setImagesFilesName()
-CString getCurrentPath(CString folderNameCategory)
-void ListFolderContents(LPCTSTR lpszFolderPath, CStringArray& fileListing)


i tray to make these functions to class function
And it still does not work

Please help!!! :)

Posted

1 solution

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.
 
Share this answer
 
Comments
Member 10631195 17-Oct-14 17:20pm    
diclaration is incompatible
Member 10631195 17-Oct-14 17:21pm    
on CStringArray Shape::setImagesFilesName()
Sergey Alexandrovich Kryukov 17-Oct-14 17:26pm    
5ed. The advice is practically good, but the problem is deeper: it's pretty apparent OP has no clue how C++ development is done in general, in this case, modularity and extern linkage.
I would only advice to grab some C++ manual/tutorial and start from scratch. If OP already done that, step back; 1-2 steps back or so.
—SA
Member 10631195 17-Oct-14 17:37pm    
Thank you very much I will check it but it's a bit annoying why I do not want to create a list for each department
nv3 17-Oct-14 18:01pm    
Perhaps you should tell us what you are trying to do.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900