Why do I get a compilation error upon specifying the return value of an overloaded type?
<p>I understand that in C++ you can overload an operator like a function. And as common with functions in C++, you have to specify a return value:</p>

<pre><code>struct A {

    int operator +();

};
</code></pre>

<p>Here I've overloaded <code>operator+</code> as a function that returns an <code>int</code>. But I find that when I overload a type while giving it a return value, I get <code>error: return type specified for 'operator int'</code>.</p>

<pre><code>struct A {

    void operator int() {} // error

};
</code></pre>

<p>But if I take away the return value it works fine.</p>

<pre><code>struct A {

    operator int() {} // pass

};
</code></pre>

<p>Does the error mean that by my use of <code>int</code> before the function parameters, that I'm creating a function that returns an <code>int</code>. Or is this some mistake? What if I want the function to not return a value? Can someone please explain why I'm getting this error? Thanks.</p>
