Looking for a simple wrapper for a dynamic array of string pointers in C++
<p>I need a simple class to wrap a c style array of pointer strings, namely <code>char **</code> <br>
I need minimal operations on my wrapper including adding elements( const or non const ), iterating, random access and querying size. I started using a std::vector like below but I don't like it for reasons described below <br>
This is my start</p>

<pre><code>struct CstrVector
{
   CstrVector(){}
    char *convertToC(const std::string &amp; str)
    {
        char *c = new char[str.size()+1];
        std::strcpy(c, str.c_str());
        return c; 
    }
    void add( const char* c)
    {
       //??
    }
    void add(const std::string&amp; str )
    {
        data.push_back(convertToC(str));
    }
    void add(const std::string&amp; s, unsigned int pos )
    {
        if( pos &lt; data.size())
        {
            data[pos] = convertToC(s);
        }
    } 
   ~CstrVector()
   {
     for ( size_t i = 0 ; i &lt; data.size() ; i++ )
     {
        delete [] data[i];
     }
   }
   char ** vdata;
  std::vector&lt;char*&gt; data; // I want to replace this with char ** vdata
};
</code></pre>

<p>Why not use <br> <code>std::vector&lt;char*&gt;</code> <br> I don't see a benefit it since I still have to allocate and free the memory outside the container ( std::vector ) anyway<br>
Why not use <br> <code>std::vector&lt;std:string&gt;</code> <br> because I want to be able to easily pass the array to a C function that will manipulate / change it contents.</p>
