title: C++ class error message: no matching function for call
body: <p>My program is supposed to calculate the surface area and volume of a box.  I am to have the following functions: setHeight, setWidth, setLength, getVolume, getSurfaceArea.</p>
  
  <p><strong>When I compile my program I get the following error message:</strong></p>
  
  <pre><code>boxMain.cpp: In function ‘int main()’:
  boxMain.cpp:21: error: no matching function for call to 'Box::getVolume(double&amp;, double&amp;, double&amp;)’
  Box.hpp:20: note: candidates are: double Box::getVolume()
  boxMain.cpp:23: error: no matching function for call to ‘Box::getSurfaceArea(double&amp;, double&amp;, double&amp;)’
  Box.hpp:21: note: candidates are: double Box::getSurfaceArea()
  </code></pre>
  
  <p>Based on my searches on this site, most answers seem to suggest that the default constructor doesn't exit or isn't working.  I don't know if that is my issue as well, but I wrote the code for my default constructor according to textbook, so I have trouble figuring out what I did wrong.  </p>
  
  <p>The missing lines in my code below are just the descriptions and comments that I removed.</p>
  
  <p><strong>Any help would be appreciated!  Thank you all so much in advance.</strong></p>
  
  <p>Here is my .hpp file:</p>
  
  <pre><code> #include &lt;iostream&gt;
   #ifndef Box_HPP
   #define BOX_HPP
  
   class Box {
  
   private:
      double h, w, l;
      double height, width, length;
  
   public:
      void setHeight(double h);
      void setWidth(double w);
      void setLength(double l);
      double getVolume();
      double getSurfaceArea();
      Box();
   };
  </code></pre>
  
  <p>Here is my function .cpp file:</p>
  
  <pre><code> #include &lt;iostream&gt;
   #include &lt;iomanip&gt;
   #include "Box.hpp"
  
   double height;
   double width;
   double length;
  
   Box::Box() {
      height = 1.0;
      width = 1.0;
      length = 1.0;
   }
  
   void setHeight(double h) {
      if(h &lt; 0) {
         std::cout &lt;&lt; "Error. Height must be positive."
                   &lt;&lt; std::endl;
      }
      else {
      height = h;
      }
   }
  
   void setWidth(double w) {
      if(w &lt; 0) {
         std:: cout &lt;&lt; "Error. Width must be positive."
                    &lt;&lt; std::endl;
      }
      else {
      width = w;
      }
   }
  
   void setLength(double l) {
      if(l &lt; 0) {
         std::cout &lt;&lt; "Error.  Length must be positive."
                   &lt;&lt; std::endl;
      }
      else {
      length = l;
      }
   }
  
   double getVolume() {
      return (height * width * length);
   }
  
   double getSurfaceArea() {
      return (2.0 * length * height + 2.0 * width * height);
   }
  </code></pre>
  
  <p>Here is my main .cpp file:</p>
  
  <pre><code> #include &lt;iostream&gt;
   #include &lt;fstream&gt;
   #include "Box.hpp"
  
   int main() {
       Box box1;
       double h, w, l;
  
       std::cout &lt;&lt; "Enter height" &lt;&lt; std::endl;
       std::cin &gt;&gt; h;
       std::cout &lt;&lt; "Enter width" &lt;&lt; std::endl;
       std::cin &gt;&gt; w;
       std::cout &lt;&lt; "Enter length" &lt;&lt; std::endl;
       std::cin &gt;&gt; l;
  
       void setHeight(double h);
       void setWidth (double w);
       void setLength (double l);
  
       std::cout &lt;&lt; "volume: "
            &lt;&lt; box1.getVolume(h, w, l) &lt;&lt; std::endl;
       std::cout &lt;&lt; "surface: "
            &lt;&lt; box1.getSurfaceArea(h, w, l) &lt;&lt; std::endl;
  
       return 0;
   }
  </code></pre>