Why is this chaining method not working?
<p>It's a simple counter. The method <code>add</code> is being called to increment the private variable <code>count</code> by 1 by default. I am returning the <code>Counter</code> class from the function so that it may be chained, but when I look at the output, it gives me 1 when I expect it to be 3 because I called <code>add</code> three times.</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;

using std::cout;

class Counter {
    public:
        Counter() : count(0) {}

        Counter add() {
            ++count; return *this;
        }

        int getCount() {
            return count;
        }
    private:
        int count;
};

int main() {

    Counter counter;

    counter.add().add().add();

    cout &lt;&lt; counter.getCount();

}
</code></pre>
