While tryin some stuff I wanted to make an example using c++ shell online which has only 1 file.
I tried making an example where you pass this by reference like this:
// Example program
#include <iostream>
#include <string>
class B;
class A{
public:
void passMe(){
B b;
b->handle(*this);
};
void runMe(){
std::cout << "Did run. ";
};
};
class B{
public:
void handle(A& refer){
refer.runMe();
};
};
int main()
{
A a;
a.passMe();
}
But I have a circular reference. Normaly you would foreward declare (with an include in the cpp file) but as far as I know thats not posible in the example given (where you need to use 1 file).
Are there other options to make the example code work?