I'm having some difficulties with this problem.
The main idea is, I initialized a variable of class type B in class A, class A.h has the variable Z declared as public, like B *Z;
In class A.cpp, I initialized it as Z = new B();
Now, I want to access that variable from class C and I'm unable to do so. C.h includes A.h and B.h
Here goes a bit of code:
Car.h
#include "Model.h"
class Car {
public:
static Model *Z;
}
Car.cpp
#include "Car.h"
void Car::init() {
Z = new Model();
}
Model.h
Class Model {}
Camera.h
#include "Model.h"
#include "Car.h"
class Camera {}
Camera.cpp
Camera::init() {
Car::Z->getPos();
}