<p>I am trying to iterate over all the elements of a static array of strings in the best possible way. I want to be able to declare it on one line and easily add/remove elements from it without having to keep track of the number. Sounds really simple, doesn't it?</p>

<p>Possible non-solutions:</p>

<pre><code>vector&lt;string&gt; v;
v.push_back("abc");
b.push_back("xyz");

for(int i = 0; i &lt; v.size(); i++)
    cout &lt;&lt; v[i] &lt;&lt; endl;
</code></pre>

<p>Problems - no way to create the vector on one line with a list of strings</p>

<p>Possible non-solution 2:</p>

<pre><code>string list[] = {"abc", "xyz"};
</code></pre>

<p>Problems - no way to get the number of strings automatically (that I know of).</p>

<p>There must be an easy way of doing this.</p>

Problems - no way to get the number of strings automatically (that i know of).
There is a bog-standard way of doing this, which lots of people (including MS) define macros like
```
arraysize
```
for:
```
```
#define arraysize(ar)  (sizeof(ar) / sizeof(ar[0]))
```
```