So I have a class which holds a struct inside its private variables and inside this struct I have an array where the size of the array is only determined after the construction of the class.
template <typename T>
class btree {
public:
btree(size_t maxNodeElems);
~btree() {}
private:
// The details of your implementation go here
size_t maxNodeElems;
struct node {
list <T> elements;
node lvl[];
};
};
Firstly, do I have to make it so its node * lvl
and how do I call the variables inside this struct? Is it the same as a private variable, so whenever I use it inside one of the functions in btree class
I can call it be btree.lvl
or is it btree->node->lvl
or is there a special way to do this?
Also, my array has to be of maxNodeElems+1
if someone can help me, that'd be much appreciated!
You are just declaring the type, not an actual object of that type. You need to make your struct declaration public and the object private:
You can create objects of that type from outside:
For accessing members, you can have public getters & setters in your btree class:
EDIT:
The following works for me (initializing the member):