So for my code I want to build a quadtree. This means I have to subdivide a dataset. To solve this I want to have external nodes (class A) and internal nodes (class B) and a way to convert an external node into an internal node.
Is there a way to let a class A convert itself into class B in a way that it can be done from inside class A itself, while preserving the pointer that points to it?
I'm sorry, but I don't know how to explain this more clearly.
class A{
public:
int a;
int b;
int c;
void convert(){
*convert class A into class B: conserving int a and int b, and discarding int c*
}
};
class B{
public:
int a;
int b;
void* One; // can be a pointer to an instance of class A or class B
void* Two; // can be a pointer to an instance of class A or class B
};
Edit: thanks for the feedback, I will rethink my strategy.
Edit2: I found an answer for not storing useless pointers here: https://stackoverflow.com/a/48330314/6859125