If I have a binary search tree header file BST.h
and inside it I have:
template <class type>
struct bstNode
{
type info;
bstNode * lLink;
bstNode * rLink;
};
And then I have an AVL.h
header file and I want to use the bstNode
struct in my AVL.h
file like this:
template<class type>
struct avlNode
{
bstNode<type> bstN;
int height;
avlNode(const type & data, bstNode<type> *ll, bstNode<type> *rl, int h = 0)
: //how would the initialization go here?
};
My question is how would I initialize the avlNode
constructor with the initializer list syntax? I'm not sure how to access the members in bstN
.
I can do it with the traditional definition outside the struct:
template<class type>
avlNode<type>::avlNode(const type & data, bstNode<type> *ll, bstNode<type> * rl, int h)
{
bstN->info = data;
bstN->lLink = ll;
bstN->rLink = rl;
height = h;
}
But I would Like to learn the syntax for the member initialization list when it comes to using an object (bstN
) from another class/struct.