operator overload to preety print enum class : <p>I am trying to print the enum class(will use some kind of map to print car, house).</p>

<p>In below code where should I stick the function to operator overload &lt;&lt; ?</p>

<p>PS: this is a contrived example.</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;memory&gt;

enum class property_type {CAR, HOUSE};

class Property
{
    public:
    virtual property_type type() = 0;
};

class Car : public Property
{
    public:
    Car(std::string name) : mName(name) {}
    std::string mName;
    property_type type() {return property_type::CAR;}
};

class House : public Property
{
    public:
    House(std::string name) : mName(name) {}
    std::string mName;
    property_type type() {return property_type::HOUSE;}
};

class Person
{
    public:
    std::vector&lt; std::shared_ptr&lt;Property&gt; &gt; properties;
};

int main()
{
    Person x;
    auto y = std::shared_ptr&lt;Property&gt;(new Car("my car"));
    auto z = std::shared_ptr&lt;Property&gt;(new House("my house"));
    x.properties.push_back(y);
    x.properties.push_back(z);
    for (auto i : x.properties) {
            std::cout &lt;&lt; i-&gt;type() &lt;&lt; std::endl;
    }
    return 0;
}  
</code></pre>
