title: Passing pointer of an object to another class in its constructor
body: <p><a href="https://stackoverflow.com/questions/7929477/explain-the-error-iso-c-forbids-declaration-of-personlist-with-no-type">This</a> question is somewhat related but still doesn't solves my problem. Consider two classes A and B:</p>
  
  <pre><code>class A{
  public:
      A(int id, B* coordinator);
      virtual ~A();
      B *coordinator;
  }
  class B{
  public:
      B(int id, int param2);
      virtual ~B();
      run();
  }
  
  void b::run(){
      while(true){
        A(1, this);
        A(2, this);
        //something else create which may create more A
      }
  }
  
  int main(int argc, char* argv[]) {
      B bObj(atoi(argv[1]), atoi(argv[2]));
  }
  </code></pre>
  
  <p>In main function I create an object of class B type called as bObj. Constructor of B calls run() and B.run() goes in an infinite loop. Where it creates multiple objects of A.
  Now I want to pass a pointer of bObj to newly created objects of class A, so that they can access other public variables and functions of bObj. So I am passing <em>this</em> pointer while creating objects of A from B. And I have declared a class variable <em>coordinator</em> of B* type in class A. But I am getting this: Compiler error -> <em>ISO C++ forbids declaration of ‘B’ with no type</em>.</p>
  
  <p>Please help me with this. I am fairly new to C++.</p>