Call class B from Class A I have two classes in my sketch that are independent of each other (a serial output and an LCD display) A simplified structure of my code is as follows:
class A
{
  public:
   int x;
   void afoo()
   {
     x=1;
   }
   void afoo2
   {
     x=ClassB.bfoo+1;
   }
};

A ClassA;

class B
{
  public:
    int y;
    void bfoo()
    {
      y=ClassA.afoo+2;
    }
};
B ClassB;

However, if I don't comment out  class afoo2 I get the following error:

exit status 1
'ClassB' was not declared in this scope

I'm guessing that this is because I haven't yet created B ClassB while class is being defined. Is there a way I can do what I'm intending here?
You can't see non-static member variables in a class like that.  The closest is to make it static, which means you get one and only one copy of the variable across all instances of your class:

class ClassB;
class ClassA {
    public:
        int x;
        void foo();

};
class ClassB {
    public:
        static int bfoo;
};

void ClassA::foo() {
    x = ClassB::bfoo + 1;
}


However I suspect that isn't what you want. I suspect you actually want to see the bfoo value stored in class instance B - so you need to tell you classA instance A what and where B is. To do that you will have to pass it when constructing or during some other setup phase.  If you want A to know B and B to know A you can't easily do it during construction, so you will have to do it at a later stage:

class ClassB;

class ClassA {
    public:
        ClassB *B;
        int fooa;
        void begin(ClassB *b) {
            B = b;
        }
        void foo();
};
class ClassB {
    public:
        ClassA *A;
        int foob;
        void begin(ClassA *a) {
            A = a;
        }
        void foo();
};

void ClassA::foo() {
    fooa = B-&gt;foob + 1;
}

void ClassB::foo() {
    foob = A-&gt;fooa + 1;
}

ClassA A;
ClassB B;

void setup() {
    A.begin(&amp;B);
    B.begin(&amp;A);
}

void loop() {

}