converting from enum to int
<p>I have declared the following enum :</p>

<pre><code>  enum periods {one, five, ten, fifteen, thirty};
</code></pre>

<p>and now I want to pass it as a commandline argument in my main function. </p>

<pre><code>int main(int argc, char* argv[]) {

  periods mp;
  if (argc == 2) {
      std::string min_prd(argv[2]);
      mp=atoi(min_prd.c_str());
 }
</code></pre>

<p>and the compiler complains:</p>

<pre><code>error: invalid conversion from ‘int’ to ‘periods’
</code></pre>

<p>I did atoi() because I figured enum is an int - how do I fix my code?</p>
