title: Area of a square, circle, and rectangle using inheritance in C++
body: <p>I am having an issue with my program in C++.  I need to find the area of a square, circle, and rectangle.  I have everything down with the circle and square but the rectangle and the shape (inheritance structure) are giving me the aforementioned issues.  I have been beating my head against a wall trying to figure this out so if anyone could help me I would greatly appreciate it.  My code is:</p>
  
  <pre><code>main.cpp
  #include &lt;iostream&gt;
  #include "Circle.h"
  #include "Square.h"
  #include "Rectangle.h"
  
  using namespace std;
  
  int main()
  {
  double radius = 0;
  double length = 0;
  double width = 0;
  Square square;
  Circle circle;
  Rectangle rectangle;
  int option;
  
  cout &lt;&lt; "Calculating the Area" &lt;&lt; endl &lt;&lt; endl;
  
  do
  {
  cout &lt;&lt; "Pick a shape in which you would like the area of:" &lt;&lt; endl;
  cout &lt;&lt; "1: Square" &lt;&lt; endl;
  cout &lt;&lt; "2: Circle" &lt;&lt; endl;
  cout &lt;&lt; "3: Rectangle" &lt;&lt; endl;
  cout &lt;&lt; "4: Exit" &lt;&lt; endl;
  cout &lt;&lt; "Please enter your choice: ";
  cin &gt;&gt; option;
  
  switch(option)
  {
  case 1:
      {
          cout &lt;&lt; endl;
          cout &lt;&lt; "Please enter the length of one side of the square: " &lt;&lt; endl;
          cin &gt;&gt; length;
          Square square(length);
          cout &lt;&lt; "The area of the square is: " &lt;&lt; square.getArea() &lt;&lt; "\n\n";
          break;
      }
  case 2:
      {
          cout &lt;&lt; endl;
          cout &lt;&lt; "Please enter the radius of the circle: ";
          cin &gt;&gt; radius;
          circle.setRadius(radius);
          cout &lt;&lt;  "The area of the circle is: " &lt;&lt; circle.getArea() &lt;&lt; "\n\n";
          break;
      }
  case 3:
      {
          cout &lt;&lt; endl;
          cout &lt;&lt; "Please enter the length of one side of the rectangle: ";
          cin &gt;&gt; length;
          rectangle.setLength(length);
          cout &lt;&lt; "Please enter the width of one side of the rectangle: ";
          cin &gt;&gt; width;
          rectangle.setWidth(width);
          cout &lt;&lt; "The area of the rectangle is: " &lt;&lt; rectangle.getArea();
      }
  }
  }
  while (option != 4);
      cout &lt;&lt; "Bye!" &lt;&lt; endl;
  
  }
  </code></pre>
  
  <p>shape.h</p>
  
  <pre><code>#ifndef SHAPE_H_INCLUDED
  #define SHAPE_H_INCLUDED
  
  class Shape {
  public:
      double getArea();
  };
  
  #endif // SHAPE_H_INCLUDED
  </code></pre>
  
  <p>shape.cpp</p>
  
  <pre><code>#include "shape.h"
  
  Shape::Shape() {
      area = 0;
  }
  
  double Shape::getArea() {
      return area;
  }
  </code></pre>
  
  <p>rectangle.h</p>
  
  <pre><code>#ifndef RECTANGLE_H_INCLUDED
  #define RECTANGLE_H_INCLUDED
  #include &lt;iostream&gt;
  #include "shape.h"
  
  class Rectangle : public Shape
  {
  public:
  Rectangle (double length = 0, double width = 0);
  double getLength = 0;
  double getWidth = 0;
  void setLength(double length);
  void setWidth(double width);
  double getArea();
  private:
  double length;
  double width;
  };
  
  
  #endif // RECTANGLE_H_INCLUDED
  </code></pre>
  
  <p>rectangle.cpp</p>
  
  <pre><code>#ifndef RECTANGLE_H_INCLUDED
  #define RECTANGLE_H_INCLUDED
  #include &lt;iostream&gt;
  #include "shape.h"
  
  class Rectangle : public Shape
  {
  public:
  Rectangle (double length = 0, double width = 0);
  double getLength = 0;
  double getWidth = 0;
  void setLength(double length);
  void setWidth(double width);
  double getArea();
  private:
  double length;
  double width;
  };
  
  
  #endif // RECTANGLE_H_INCLUDED
  </code></pre>
  
  <p>I only included the ones I am having trouble with.  Seeing as how I know my other ones work and that this is a rewrite of a program I did last week.  Every time I try to build it I get these two errors.</p>
  
  <p>Definition of implicitly-declared 'Shape::shape()'
  area was not declared in this scope.</p>
  
  <p>Any help would be greatly appreciated.</p>