0

I have for instance 3 headers and 3 corresponding cpp files for each header, as well as a main.cpp. To save time for this question, I decided to put the methods inside of the header. I'm trying to access the methods in each class. 2 of the classes need methods from each other class, while the third class does not need anything and can be left alone. I read some things and they said to use forward declarations for each class, but I couldn't figure out how to do that with 3 headers. using #include "A.h" or #include "B.h" or #include "C.h" gave me errors that the type did not exist. With the code below which is what I am currently using, I am getting a "error: '//method()//' was not declared in this scope" error for each of them. Any solutions?

//////A.h file
class A{
  B *b;
  C *c
  void SomeAMethod() {
    //do something
    //using A assets
  }
  void anotherAMethod(){
    b->anotherBMethod();
    c->SomeCMethod();
};

///////B.h file
class B{
  A *a
  C *c
  void SomeBMethod(){
    //do something
    //using B assets
  }
  void anotherBMethod(){
    a->anotherAMethod();
    c->SomeCMethod();
};

//////C.h file   
class C{
  void SomeCMethod(){
    //do something
    //using C assets
  }
};

0 Answers0