#include <iostream>
#include <string.h>
#pragma warning(disable : 4996)
#define MaxWordSize 100
// Declare a structure that holds data in a node
typedef struct {
int num;
} NodeDataInt;
// Declare a structure that holds data in a node
typedef struct {
char word[MaxWordSize + 1];
int freq;
} NodeDataChar;
// define what a node will look like
typedef struct treenodeInt {
NodeDataInt data;
struct treenode* left, * right;
} t2;
// define what a node will look like
typedef struct treenodeChar {
NodeDataChar data;
struct treenode *left, *right;
} t3;
// main method
int main()
{
// Node with integer data
NodeDataInt aNode;
aNode.num = 100;
std::cout << "aNode.num: " << aNode.num << "\n";
// Node with character data
NodeDataChar aNodeChar;
strcpy(aNodeChar.word, "Hello Word");
std::cout << "aNodeChar.word: " << aNodeChar.word << "\n";
//syntax error
//t2.data.num = 1000;
// example using tree node with int data
t2 aTNode;
aTNode.data.num = 1000;
std::cout << "aTNode.data.num: " << aTNode.data.num << "\n";
// example using tree node with char data
t3 aTNodeChar;
strcpy(aTNodeChar.data.word, "1000 Hello Node Char Data");
std::cout << "aTNodeChar.data.word: " << aTNodeChar.data.word << "\n";
}
Jul 20