Conversion between enum and string in C++ class header
I would use some template logic to achieve the affect in a more scalable way:

#include &lt;iostream&gt;
#include &lt;sstream&gt;
#include &lt;string&gt;
#include &lt;algorithm&gt;

// This is the type that will hold all the strings.
// Each enumeration type will declare its own specialization.
// Any enum that does not have a specialization will generate a compiler error
// indicating that there is no definition of this variable (as there should be
// be no definition of a generic version).
template&lt;typename T&gt;
struct enumStrings
{
    static char const* data[];
};

// This is a utility type.
// Created automatically. Should not be used directly.
template&lt;typename T&gt;
struct enumRefHolder
{
    T&amp; enumVal;
    enumRefHolder(T&amp; enumVal): enumVal(enumVal) {}
};
template&lt;typename T&gt;
struct enumConstRefHolder
{
    T const&amp; enumVal;
    enumConstRefHolder(T const&amp; enumVal): enumVal(enumVal) {}
};

// The next two functions do the actual work of reading/writing an
// enum as a string.
template&lt;typename T&gt;
std::ostream&amp; operator&lt;&lt;(std::ostream&amp; str, enumConstRefHolder&lt;T&gt; const&amp; data)
{
   return str &lt;&lt; enumStrings&lt;T&gt;::data[data.enumVal];
}

template&lt;typename T&gt;
std::istream&amp; operator&gt;&gt;(std::istream&amp; str, enumRefHolder&lt;T&gt; const&amp; data)
{
    std::string value;
    str &gt;&gt; value;

    // These two can be made easier to read in C++11
    // using std::begin() and std::end()
    //  
    static auto begin  = std::begin(enumStrings&lt;T&gt;::data);
    static auto end    = std::end(enumStrings&lt;T&gt;::data);

    auto find   = std::find(begin, end, value);
    if (find != end)
    {   
        data.enumVal = static_cast&lt;T&gt;(std::distance(begin, find));
    }   
    return str;
}


// This is the public interface:
// use the ability of function to deduce their template type without
// being explicitly told to create the correct type of enumRefHolder&lt;T&gt;
template&lt;typename T&gt;
enumConstRefHolder&lt;T&gt;  enumToString(T const&amp; e) {return enumConstRefHolder&lt;T&gt;(e);}

template&lt;typename T&gt;
enumRefHolder&lt;T&gt;       enumFromString(T&amp; e)     {return enumRefHolder&lt;T&gt;(e);}


Then you can use it like this:

// Define Enum Like this
enum X {Hi, Lo};
// Then you just need to define their string values.
template&lt;&gt; char const* enumStrings&lt;X&gt;::data[] = {"Hi", "Lo"};

int main()
{
    X   a=Hi;

    std::cout &lt;&lt; enumToString(a) &lt;&lt; "\n";

    std::stringstream line("Lo");
    line &gt;&gt; enumFromString(a);

    std::cout &lt;&lt; "A: " &lt;&lt; a &lt;&lt; " : " &lt;&lt; enumToString(a) &lt;&lt; "\n";
}