title: Using an object from a class as an object for another class c++
body: <p>I'm writing a C++ program and I have to use an instance of a class as private member of another class. The code for the class I need to use as a member instance is the as follow:</p>
  
  <pre><code>class Triangle
  {
      public:
          Triangle(int _height, int _base){ set(_height, _base); } 
          //constructor
          void set(int _height, int _base){ height = _height; base = _base; }
          int area(){ return ((height*base)/2); }
          int perimeter(){ return (2*(sqrt(((base/2)*(base/2)) +. (height*height))) + base); }
      private:
          int height; 
          int base; 
   };
  </code></pre>
  
  <p>And here is the definition for the class that will use the above instance as private member:</p>
  
  <pre><code>Class Penta
  {
      Public:
          Penta(int b );
          Penta(){ TriPart.set(10, 10); }
      Private:
          Triangle TriPart;
  };
  </code></pre>
  
  <p>When I compile the above code compilation fails with the following error:</p>
  
  <pre><code>error: no matching function for call to 'Triangle::Triangle()'
  </code></pre>
  
  <p>I really appreciate if you can help me with this.</p>