-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTreeNode.h
More file actions
38 lines (28 loc) · 945 Bytes
/
TreeNode.h
File metadata and controls
38 lines (28 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//Â Created by Frank M. Carrano and Timothy M. Henry.
//Â Copyright (c) 2017 Pearson Education, Hoboken, New Jersey.
/** A class of nodes for an array-based binary tree.
Listing 16-1.
@file TreeNode.h */
#ifndef TREE_NODE_
#define TREE_NODE_
template<class ItemType>
class TreeNode
{
private:
ItemType item; // Data portion
int leftChild; // Index to left child
int rightChild; // Index to right child
public:
TreeNode();
TreeNode(const ItemType& nodeItem, int left, int right);
// Declarations of the methods setItem, getItem, setLeft, getLeft,
// setRight, and getRight are here.
void setItem(const ItemType& anItem);
ItemType getItem() const;
void setLeft(TreeNode<ItemType> leftChild);
TreeNode<ItemType> getLeft() const;
void setRight(TreeNode<ItemType> rightChild);
TreeNode<ItemType> getRight() const;
}; // end TreeNode
#include "TreeNode.cpp"
#endif