Firstly, I've read most of the topics on circular dependency here and there with no luck to my problem... so I boiled it down to a simple example, could have gone with A and B naming but this way maybe the goal's more clear.
I understand that the compiler can't know the size to allocate this way but forward declaration would leave me with an incomplete type which wouldn't work either.
My last guess would be to make a third class, but I find this over complicated ...any suggestions?
file Layer.h
#ifndef LAYER
#define LAYER
#include Shape.h
struct Layer {
int *bufferid
Shape *canvas = new Shape(); // here i need to know about Shape
void draw() { canvas->draw(); }
}
#endif
file Shape.h
#ifndef SHAPE
#define SHAPE
#include Layer.h
struct Shape {
void draw(Layer *layer) { draw(layer->buffer); } // here I need to know about Layer
void draw(int *bufferid = nullptr) { /* if nullptr render to output else to buffer */ }
}
#endif