How do I use a Java-like C++ enum as a member variable of another class?
<p>I'm trying to use the <a href="http://stackoverflow.com/a/1965344/79217">solution for java-like enums in C++</a>.</p>

<p>My Problem is that I'm trying to use the enum as a member in another class.
So first we start with the familiar Planet enum:</p>

<pre class="lang-cpp prettyprint-override"><code>#ifndef PLANETS_H
#define PLANETS_H

class Planet {
  public:
    static const double G = 6.67300E-11;
    // Enum value DECLARATIONS - they are defined later
    static const Planet MERCURY;
    static const Planet VENUS;
    // ...

  private:
    double mass;   // in kilograms
    double radius; // in meters

  private:
    Planet(double mass, double radius) {
        this-&gt;mass = mass;
        this-&gt;radius = radius;
    }

  public:

    double surfaceGravity() {
        return G * mass / (radius * radius);
    }
};

// Enum value DEFINITIONS
// The initialization occurs in the scope of the class,
// so the private Planet constructor can be used.
const Planet Planet::MERCURY = Planet(3.303e+23, 2.4397e6);
const Planet Planet::VENUS = Planet(4.869e+24, 6.0518e6);

#endif // PLANETS_H
</code></pre>

<p>Then we have a <code>SolarSystem</code> object that takes <code>Planet</code> objects.</p>

<pre class="lang-cpp prettyprint-override"><code>#ifndef SOLARSYSTEM_H
#define SOLARSYSTEM_H

#include "Planets.h"
class SolarSystem {
  public:
    SolarSystem(int distance, const Planet&amp; planet) {
        this-&gt;distance = distance;
        this-&gt;planet = planet;
    }

  private:
    int distance;   // in kilometers
    Planet planet;

};


#endif // SOLARSYSTEM_H
</code></pre>

<p>Now if we try to compile this we get the following errors:</p>

<pre class="lang-none prettyprint-override"><code>SolarSystem.h: In constructor 'SolarSystem::SolarSystem(int, const Planet&amp;)':
SolarSystem.h:7:53: error: no matching function for call to 'Planet::Planet()'
SolarSystem.h:7:53: note: candidates are:
Planets.h:17:5: note: Planet::Planet(double, double)
Planets.h:17:5: note:   candidate expects 2 arguments, 0 provided
Planets.h:4:7: note: Planet::Planet(const Planet&amp;)
Planets.h:4:7: note:   candidate expects 1 argument, 0 provided
</code></pre>

<p>The problem can be fixed by including an empty <code>Planet()</code> constructor.</p>

<p>I was wondering if that is the most appropriate fix or if there is a solution that does not involve an empty constructor.</p>
