Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to create an Array of CStringArrays.
How to declare and initialize this Array.

Thanks for your help
Posted

Try this :) :
C++
typedef std::auto_ptr<CStringArray> CSafeChapters;
typedef CArray<CSafeChapters, CSafeChapters> CCategories;

class CTest
{
  CCategories m_arCategories;
  
public:
  CTest()
  {
    m_arCategories.Add(CSafeCapters(new CStringArray));
    m_arCategories.Add(CSafeCapters(new CStringArray));
    m_arCategories.Add(CSafeCapters(new CStringArray));
    m_arCategories.Add(CSafeCapters(new CStringArray));

    m_arCategories[0]->Add(_T("Chapter I"));
    m_arCategories[0]->Add(_T("Chapter II"));
    m_arCategories[0]->Add(_T("Chapter III"));
  }

  ~CTest()
  { // set a breakpoint here to discover all destructors' calls by F11 key :)
  }
} cTest;
 
Share this answer
 
v3
You should not be using CStringArrays, you should use the standard library, std:list, std:vector, etc. But if you must, then

CStringArray[] strings = new CStringArray[] ();

From memory, I'm a long way from c++ and I NEVER used these MFC classes that were only ever meant as a stop gap until the STL arrived ( over a decade ago ).
 
Share this answer
 
I think so Christian. Because i never used array of CStringArray. There are many other classes better than CStringArray. Other wise use
C++
std:list
. I think
C++
CStringList
is good one.
 
Share this answer
 

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