我想创建CStringArrays数组并执行操作 [英] I want to create Array of CStringArrays and do operations

查看:78
本文介绍了我想创建CStringArrays数组并执行操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个CStringArrays数组.
如何声明和初始化此Array.

感谢您的帮助

I want to create an Array of CStringArrays.
How to declare and initialize this Array.

Thanks for your help

推荐答案

尝试一下:):
Try this :) :
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;


您不应该使用CStringArrays,应该使用标准库std:list,std:vector等.但是,如果必须,则

CStringArray []字符串=新的CStringArray []();

从内存来看,我与c ++距离很远,而且我从来没有使用过这些MFC类,这些类只是在STL到来之前(十多年前)才是一个停顿.
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 ).


I以为是基督徒.因为我从未使用过CStringArray数组.还有许多其他比CStringArray更好的类.否则,请使用
I think so Christian. Because i never used array of CStringArray. There are many other classes better than CStringArray. Other wise use
std:list

.我认为

CStringList

是不错的选择.


这篇关于我想创建CStringArrays数组并执行操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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