C++: String and unions
<p>I'm having a (design) problem:
I'm building an interpreter and I need some storage for variables. There are basically two types of content a variable here can have: <code>string</code> or <code>int</code>.</p>

<p>I'm using a simple class for the variables, all variables are then stored in a vector.</p>

<p>However, as a variable can hold a number or a string, I don't want C++ to allocate both and consume memory for no reason.</p>

<p>That's why I wanted to use unions:</p>

<pre><code>union
{
 string StringValue;
 int IntValue;
}
</code></pre>

<p>However, strings don't work with unions.</p>

<ul>
<li>Is there any workaround so no memory gets eaten for no reason?</li>
</ul>
