So basically I have 2 classes, BSTNode class and BST class, BSTNode is friend of BST.
In my BST class , I have these public functions
void BST::Insert(int val);
{
..do stuff
}
void BST::PostorderDFT(BSTNode* node)
{
...do stuff
}
I know that I have to create an object. Lets say :
int main(void)
{
BST bst1;
//then use the object I just created to create a tree. Lets say:
{
bst1.Insert(1);
bst1.Insert(2);
bst1.Insert(4);
bst1.Insert(10);
ect..
So my question is, how can I call the PostorderDFT(BSTNode* node) function in main function. Or what argument should I pass to make it work because the parameter (BSTNode* node) is a class pointer, so it is quite hard to understand.
Thank you.
You can define a variables of BSTNode like this:
BSTNode node;
You can use a constructor as follow:
BSTNode node(0,NULL,NULL);
Then, You can assignment for this variables as usual,Finally,You can use this variables like this:
// some assignment
// ...
bst1.PostorderDFT(&node);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.