title: Return type is not identical to nor covariant with return type (operator++)
body: <p>I have the following error: <br>IntelliSense: return type is not identical to nor covariant with return type "Counter" of overridden virtual function "Counter::operator++"</p>
  
  <p>Here are the headers of my project.<br>
  <strong>counter.h</strong></p>
  
  <pre><code>/* Header file of Counter Class*/
  #pragma once
  #include &lt;iostream&gt;
  using namespace std;
  //Class definition
  class Counter {
      friend ostream &amp;operator&lt;&lt;(ostream &amp;out, const Counter &amp;c);
      public:
          Counter(int n0 = 0);
          virtual Counter &amp;operator++();
          virtual Counter operator++(int);
          void reset();
          int getCount() const;
  
      private:
          int count;
  };
  </code></pre>
  
  <p><strong>LimitedCounter.h</strong></p>
  
  <pre><code>#pragma once
  #include "counter.h"
  
  class LimitedCounter : public Counter{
      friend ostream &amp;operator&lt;&lt;(ostream &amp;out, const LimitedCounter &amp;c);
  public:
      LimitedCounter(int low, int up);
      void reset();
      LimitedCounter&amp; operator++();
      LimitedCounter operator++(int); // error here
      operator int() { return getCount(); };
      int getCount() const { return Counter::getCount(); };
  private:
      int upper;
  
  };
  </code></pre>
  
  <p>And the implementation<br>
  <strong>counter.cpp</strong></p>
  
  <pre><code>/* Implementation of Counter Class*/
  
  #include "counter.h"
  #include &lt;iostream&gt;
  
  Counter:: Counter(int n0) {
       count = n0;
  }
  Counter&amp; Counter::operator++() {
     count++;
     return *this;
  }
  Counter Counter::operator++(int) {
     Counter old = *this;;
     count++;
     return old;
  }
  void Counter::reset(){
     count = 0;
  }
  int Counter::getCount() const{
     return count;
  }
  ostream &amp;operator&lt;&lt;(ostream &amp; out, const Counter &amp;c) {
       out &lt;&lt; "\nCounter value is now " &lt;&lt; c.count ;
       return out;
  }
  </code></pre>
  
  <p><strong>LimitedCounter.cpp</strong></p>
  
  <pre><code>#include "LimitedCounter.h"
  LimitedCounter::LimitedCounter(int low, int up) : Counter(low), upper(up) {}
  
  LimitedCounter&amp; LimitedCounter::operator++() {
      if (getCount() &lt; upper) {
          Counter::operator++();
      }
      return *this;
  }
  
  LimitedCounter LimitedCounter::operator++(int) {
      if (getCount() &lt; upper) {
          LimitedCounter old = *this;
          Counter::operator++(0); // question?
          return old;
      }
      else {
          return *this;
      }
  }
  
  void LimitedCounter::reset() {
      Counter::reset();
  }
  
  //friend function
  ostream &amp;operator&lt;&lt;(ostream &amp;out, const LimitedCounter &amp;c) {
      out &lt;&lt; c.getCount() &lt;&lt; endl;
      return out;
  }
  </code></pre>
  
  <p>I get the error: <br>error C2555: 'LimitedCounter::operator ++': overriding virtual function return type differs and is not covariant from 'Counter::operator ++'   </p>
  
  <p>When I remove <strong>virtual</strong> in the <strong>post-increment</strong> of <strong>counter.h</strong> then there is no error at all. So everything works fine with the <strong>pre-increment</strong>. So I don't know is it because how I implement the <strong>post-increment</strong>? And also when I override the post-increment ( <strong>operator++(int)</strong> ), is it right that I write like this:</p>
  
  <pre><code>Counter::operator++(0);
  </code></pre>
  
  <p>Thanks for helping me.</p>