title: C++14 Class Function Error: "Object has no attribute 'value'"
body: <p><strong>EDIT:</strong> Total Overhaul</p>
  
  <p>I am making a programming language (similar to Python), and at least for now, I am trying to compile it to <code>C++</code>. I'm having an error where <code>C++</code> is saying that there is no member <code>"value"</code> in the class <code>"Object"</code>. This is a compilation error. I understand <em>why</em> <code>C++</code> is doing this, as it has to know the type of <code>value</code> at compile-time, and so I am asking for <em>alternatives</em>.</p>
  
  <p>The only things it will be given are instances subclasses of Object, in which the member <code>"value"</code> will be defined, this is a compile error.</p>
  
  <p>I can't declare the member <code>"value"</code> inside the <code>Object</code> class, because its type depends on which subclass it's in. This also has to work with floats and strings, so defining the function with an Integer instance instead of an Object instance won't work.</p>
  
  <p>Here is some code with an example of how these objects will be used:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>auto user_i = std::make_unique&lt;Integer&gt;(2);
    std::cout &lt;&lt; (*user_i).equals(*std::make_unique&lt;Float&gt;(2.0).get()) &lt;&lt; std::endl;
  </code></pre>
  
  <p>Here are the important class definitions:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>  class Object {
    public:
      bool equals(Object&amp; other) {
        throw "Not implemented!";
      }
    };
    class Integer: public Object {
    public:
      int value;
      Integer(int val) {
        value = val;
      }
      bool equals(Object&amp; other) {
        return value == other.value;
      }
    };
  class Float: public Object {
    public:
      double value;
      Float(double val) {
        value = val;
      }
      bool equals(Object&amp; other) {
        return value == other.value;
      }
    };
  class String: public Object {
    public:
      string value;
      String(string val) {
        value = val;
      }
      bool equals(Object&amp; other) {
        return value.compare(other.value) == 0;
      }
    };
  </code></pre>
  
  <p>It should not be the case that <code>2 == "2"</code>, but it should be the case that <code>2 == 2.0 == 2.000</code> etc.</p>
  
  <p>There is then the added complication of methods like <code>add</code> (by this I mean returning a value, still not modifying the object). The <code>equals</code> method suggested by @Michael Karcher would work fine, but for example <code>2+3</code> should return <code>5</code>, not <code>5.00000</code>.</p>
  
  <p>For even more trouble, User-Defined <code>Object</code>s (<code>Class</code>s in my language) should be able to override methods like <code>add</code>.</p>