title: forward declaration cpp invalid use of incomplete type
body: <p>Please note that I am writing this test code in a single TypeConversion.cpp file with no header files I am forward declaring Counter2 and trying to invoke method on it which counter2.getA(); which is giving me compile time error invalid use of incomplete type 'class Counter2' Is there any way out to resolve this error?
  Is there any sense of forwrd declaration in .cpp file or is it useful in header files only.</p>
  
  <pre><code>//TypeConversion.cpp
  #include &lt;iostream&gt;
  using namespace std;
  class Counter2;
  
  class Counter {
  
  public:
  int count;
  
  
  public :
  const int* getCount() const{return &amp;(this-&gt;count);}
  
  void setCount() {
  
      this-&gt;count=10;
  
  }
  
  // Pre-increment
  Counter operator++() {
      this-&gt;count++;
  
      return (*this);
  }
  //Post increment
  Counter&amp; operator++(int){
      Counter dummy;
      dummy.count=this-&gt;count;//(*this).n
      this-&gt;count++;
      return dummy;
  }
  
   const Counter&amp; modify() {
      this-&gt;count=111;
      return *this;
  }
  
  Counter()  {
      this-&gt;count=0;
      //this-&gt;array[5]={1,1,2,3,4};
  }
  
  /*Counter(Counter2 &amp;counter2) {
      this-&gt;count= counter2.getA() + counter2.getB();
  }*/
  
  istream&amp; operator&gt;&gt;(istream&amp; in) {
  
      in&gt;&gt;this-&gt;count;
      return in;
  }
  
  void operator=(Counter2 &amp;counter2) {
      this-&gt;count = counter2.getA() + counter2.getB();
  }
  
  /*  int&amp; operator[](int index){
      return this-&gt;array[index];
  }*/
  
  };
  
  class Counter2 {
  private:
  int a ,b;
  public:
  Counter2() {
      this-&gt;a=10;
      this-&gt;b=20;
  }
  Counter2(Counter &amp;c) {
      this-&gt;a=c.count;
      this-&gt;b=c.count;
  }
  
  int getA()  {return this-&gt;a;}
  int getB()  {return this-&gt;b;}
  
  operator Counter() {
      Counter c;
      return c;
  }
  
  };
  
  int main() {
  cout &lt;&lt; "!!!Hello World!!!" &lt;&lt; endl; // prints !!!Hello World!!!
  Counter2 c2;
  Counter c=c2;
  //c=c2;
  cout&lt;&lt;endl&lt;&lt;*(c.getCount());
  return 0;
  }
  </code></pre>