Operator overloading definition outside of the class - C++
<p>Sorry this is such a simple question. I've been using tutorialspoint.com to learn C++. Currently I'm trying to learn about classes and operator overloading. For other member function, the website uses this convention</p>

<pre><code>    class Box {
     private:
      int Volume;
     public:
      Box(int num);
      ...
     }
     Box::Box(int num) {
      Volume = num;
     }
</code></pre>

<p>However, when overloading operators, they use this</p>

<pre><code>     class Box {
      private:
       int volume;
      public:
       Box(int num);
       Box operator+(const Box &amp;b) {
        Box box;
        box.volume = this-&gt;volume + b.volume;
        return box;
       }
      }
</code></pre>

<p>They define the overloading function inside the class. Is it possible to define it outside the class? If so, how? I've tried</p>

<pre><code>     Box Box::operator+(const Box &amp;b) {...}
     Box::Box operator+(const Box &amp;b) {...}
</code></pre>

<p>But these don't work</p>

<p>How do I do this outside of a class?</p>

<p>Again, sorry this is such a simple question.
Thanks</p>

<p><strong>EDIT</strong>
My code looks like this</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;

class Box {
 private:
  int volume;
 public:
  Box(int num);
  Box operator+(const Box &amp;b);
};

Box::Box(int num) {
 volume = num;
}

Box Box::operator+(const Box &amp;b) {
 Box box;
 box.volume = this-&gt;volume + b.volume;
 return box;
}

int main() {
 Box one(2);
 Box two;
 two = one + one;  
}
</code></pre>

<p>My error is</p>

<pre><code>    Overloading.cc: In member function 'Box Box::operator+(const Box&amp;)':
    Overloading.cc:18:6: error: no matching function for call to 'Box::Box()'
    Overloading.cc:18:6: note: candidates are:
    Overloading.cc:13:1: note: Box::Box(int)
    Overloading.cc:13:1: note:   candidate expects 1 argument, 0 provided
    Overloading.cc:5:7: note: Box::Box(const Box&amp;)
    Overloading.cc:5:7: note:   candidate expects 1 argument, 0 provided
    Overloading.cc: In function 'int main()':
    Overloading.cc:25:6: error: no matching function for call to 'Box::Box()'
    Overloading.cc:25:6: note: candidates are:
    Overloading.cc:13:1: note: Box::Box(int)
    Overloading.cc:13:1: note:   candidate expects 1 argument, 0 provided
    Overloading.cc:5:7: note: Box::Box(const Box&amp;)
    Overloading.cc:5:7: note:   candidate expects 1 argument, 0 provided
</code></pre>