title: Constructor not initializing object member data
body: <p>I'm trying to learn C++, but i'm having a little bit of difficulty with this program i'm writing. Essentially, the program writes a rectangle of desired dimensions to the screen. Simple enough. However, I can't get the program to create the rectangle whose dimensions are initialized by the constructor parameters. I put a cout statement in the constructor to verify that the constructor is taking the parameters and initializing the dimension variables, and it seems to be doing its job. When I call the function to draw the rectangle or calculate the area however, it returns nothing and 0, respectively. I'm sure I've made a stupid mistake, but I cant see where I went wrong. </p>
  
  <p>Here is the code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  enum choice {DrawRect=1,GetArea,GetPerim,ChangeDimensions,Quit};
  
  //Rect Class Declaration
  
  class Rectangle
  {
  public:
  
  // Constructors
  Rectangle(int,int);
  ~Rectangle();
  
  //Accessors
  
  int GetArea() const {return itsLength * itsWidth;}
  int GetLength() const   {return itsLength;}
  int GetWidth() const    {return itsWidth;}
  int GetPerim() const    {return 2*itsWidth + 2*itsLength;}
  void ChangeDimensions(int length,int width);
  
  //Member Data
  
  int itsLength;
  int itsWidth;
  };
  
  //Implementation of Methods not defined inline
  
  Rectangle::Rectangle(int length,int width)
  {
      int itsLength = length;
      int itsWidth = width;
      cout &lt;&lt; "The constructor is creating a Rectangle with length " &lt;&lt; itsLength &lt;&lt; " and width " &lt;&lt; itsWidth &lt;&lt; "\n";
  }
  
  Rectangle::~Rectangle() {}
  
  void Rectangle::ChangeDimensions(int length,int width)
  {
      itsLength = length;
      itsWidth  = width;
  }
  
  int DoMenu();
  void    DoDrawRect(Rectangle);
  void    DoGetArea(Rectangle);
  void    DoGetPerim(Rectangle);
  
  //Main
  
  int main() 
  {   
      //Initialize Rectangle theRect
      Rectangle theRect(5,30);
  
      int fQuit=false;
      int choice = DrawRect;
  
      while (!fQuit)
      {
          choice = DoMenu();
  
          if (choice &lt; DrawRect || choice &gt; Quit)
              {
                  cout &lt;&lt; "Invalid Choice, Try Again.\n\n";
                  continue;
              }
  
          switch(choice)
              {
                  case DrawRect:
                      DoDrawRect(theRect);
                      break;
                  case GetArea:
                      DoGetArea(theRect); 
                      break;
                  case GetPerim:
                      DoGetPerim(theRect);
                      break;
                  case ChangeDimensions:
                      int newLength,newWidth;
                      cout &lt;&lt; "\nEnter new length: ";
                      cin &gt;&gt; newLength;
                      cout &lt;&lt; "\nEnter new width: ";
                      cin &gt;&gt; newWidth;
                      theRect.ChangeDimensions(newLength,newWidth);
                      DoDrawRect(theRect);
                      break;
                  case Quit:
                      fQuit=true;
                      cout &lt;&lt; "Exiting....\n\n";
                      break;
                  default:
                      cout &lt;&lt; "Error in Choice!!\n";
                      fQuit=true;
                      break;
              }
      }
      return 0;
  }
  
  
  int DoMenu()
  {   
      int choice;
      cout &lt;&lt; "\n****************";
      cout &lt;&lt; "\n      Menu\n";
      cout &lt;&lt; "****************\n";
      cout &lt;&lt; "1: Draw Rectangle\n";
      cout &lt;&lt; "2: Get Area of Rectangle\n";
      cout &lt;&lt; "3: Get Perimeter of Rectangle\n";
      cout &lt;&lt; "4: Set Dimensions of Rectangle\n";
      cout &lt;&lt; "5: Quit Program\n";
      cout &lt;&lt; ": ";
      cin &gt;&gt; choice;
      return choice;
  };
  
  void DoGetArea(Rectangle theRect)
  {
      cout &lt;&lt; "The Area of the Rectangle is " &lt;&lt; theRect.GetArea() &lt;&lt; "\n";
  };
  
  void DoGetPerim(Rectangle theRect)
  {
      cout &lt;&lt; "The Perimeter of the Rectangle is " &lt;&lt; theRect.GetPerim() &lt;&lt; "\n";
  };
  
  void DoDrawRect(Rectangle theRect)
  {
      int width = theRect.GetWidth();
      int length = theRect.GetLength();
  
      for (int i = 0;i &lt; width;i++)
          {
              for (int j = 0; j &lt; length;j++)
                  {   
                      cout &lt;&lt; "*";
                  }
              cout &lt;&lt; "\n";
          }
  
  };
  </code></pre>
  
  <p>Thanks, I appreciate any help you can give me.</p>