title: Creating and Implementing Classes in C++
body: <p>In my computer science class we are learning how to use classes to create virtual electrical components... There are five things we need to create; the main() as well as ElectricalComponent.h/.cpp, Resistor.h/.cpp, Capacitor.h/.cpp, and Battery.h/.cpp.  </p>
  
  <p>I have already created the Electrical component Class, and I know how to create and fix any errors in the main function, however I am having trouble building the Resistor Class.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "ElectronicComponent.h"
  class Resistor :
      public ElectronicComponent
  {
  public:
      Resistor(double);
      virtual ~Resistor();
      virtual double getValue() const = 0;
      virtual std::string getUnits() const = 0;
      virtual std::string to_string() const = 0;
  };
  
  Resistor::Resistor(double v)
  {
      value = v;
  }
  
  std::string Resistor::to_string() const
  {
      return "Resistor value (" + std::to_string(value) + " " + units + ")";
  }
  </code></pre>
  
  <p>I am receiving the errors that namespace std has no member to_string, and that my variables value and units are undeclared.  I understand what it means by undeclared variables, but not the to_string error.</p>
  
  <p>This is all the information that I was given regarding this Class:</p>
  
  <blockquote>
    <p>The Resistor class will be implemented with files Resistor.h and
    Resistor.cpp. The Resistor class will inherit, publicly, from
    ElectronicComponent. You need to implement a destructor and the three
    virtual functions getValue, getUnits and to_string. You will also need
    a constructor that takes one input parameter, the value of the
    resistor. The value is of type double. The getValue function needs to
    return the value as a double. The getUnits function needs to return
    “Ohm(s)” as a std::string.</p>
  </blockquote>
  
  <p>The rest of the classes should be built the same way, so understanding how one works should help me out a lot.  Thanks.</p>