I am currently in the process of coding my B+ Tree and this is the structure of my code for reference so that my proceeding question makes more sense:
Class BPlusTree{
// some functions, members.. etc
};
Class Node{
// some functions, members.. etc
}
Now, here is my question/dilemma, since my Node is a class of its own, if I want to insert a key/value pair into a node, I would have to call the BPlusTree insert function which in turn calls the Node's own insert function ( I cannot access Node's private members directly). This seems a bit weird to me.
However, if I were to simply do this in my Node Class:
friend class BPlusTree;
I would be able to access Node's private members and thus I do not need to make an insert function inside the Node class because now my BPlusTree insert function has access to the members.
Is this approach good or bad? I'm at the point where refactoring my code isn't going to be a pain so I thought I'd ask this now before it's too late.