I am supposed to make a binary hash tree mix of code. I know what I am doing for the most part, but its been a while since I have done some serious C++ coding. The compiler is yelling at me because it doesn't like my last definition in my public section of the class.

Am i getting errors about "node" because its in the private section? Thanks

Errors:

1>c:\users\adam-7\documents\computer science\cs 130a\project 1\project 1\binaryhash.h(46): error C2061: syntax error : identifier 'node'
1>c:\users\adam-7\documents\computer science\cs 130a\project 1\project 1\binaryhash.cpp(20): error C2660: 'BinaryHash::deleteNode' : function does not take 1 arguments
1>c:\users\adam-7\documents\computer science\cs 130a\project 1\project 1\binaryhash.cpp(54): error C2511: 'void BinaryHash::deleteNode(BinaryHash::node *)' : overloaded member function not found in 'BinaryHash'
1>          c:\users\adam-7\documents\computer science\cs 130a\project 1\project 1\binaryhash.h(8) : see declaration of 'BinaryHash'

BinaryHash.h:

// BinaryHash.h
// Created by Adam Ehrlich on 1/29/2012
#include <map>

#ifndef BinaryHash_H
#define BinaryHash_H

class BinaryHash {

public:
	// Default Constructor
	BinaryHash();

	// Constructor with a list of ints
	BinaryHash(int list[]);

	// Destructor
	~BinaryHash();
	// Insert value into the BST-Hash Table structure
	void insert(int value);

	// If value exists then return 1, otherwise return 0
	int find(int value);

	// Convert structure from BST to Hash Table.  If the hash table is already created
	// or value does not exists or node does not have a child in the given direction
	// prits out "ToHashTable – No Conversion"
	void ToHashTable(int value, int direction);

	// Convert left or right hash table of a node to a BST.  If the hash table in the given
	// direction or value does not exists then prints out "ToTree – No Conversion"
	void ToTree(int value, int direction);

	// Print out BST node v alues by preorder traversal.  If you hit a hash table then print out HT.
	// If there is no content to print then just print out "BST Printing - No Output"
	void printTree();

	// Print out content of a specific hash table.  Value is the parent BST node value, direction
	// represents left or right.  In fact, direction is  binary value, 0 represents left, 1 
	// represents right has tqable.  If value does not exist or there is no hash table in the given 
	// direction then print out "HT Printing - No Output"
	void printHT(int value, int direction);

	// Delete the nodes off one by one to make efficient memory usage
	// This is a recursive function
	void deleteNode(node *n);

private:
	struct node {
		// Data for a node
		int value;
		node *leftChild;
		node *rightChild;
		std::map *leftHTChild;
		std::map *rightHTChild;

		// Constructors for the node
		Node () : value(0), leftChild(0), rightChild(0), leftHTChild(0), rightHTChild(0) {}
		Node (int v, node *lc1, node *rc1, std::map *ht1, std::map *ht2) : 
			value(v), leftChild(lc1), rightChild(rc2), leftHTChild(ht1), rightHTChild(ht2) {}
	};

	node *root;
};

#endif

BinaryHash.cpp:

// BinaryHash.cpp
// Created by Adam Ehrlich on 1/29/2012

#include "stdafx.h"
#include "BinaryHash.h"
#include <iostream>

BinaryHash::BinaryHash()
{

}

BinaryHash::BinaryHash(int list[])
{

}

BinaryHash::~BinaryHash()
{
	this->deleteNode(this->root);
}

void BinaryHash::insert(int value)
{

}

int BinaryHash::find(int value)
{

}

void BinaryHash::ToHashTable(int value, int direction)
{

}

void BinaryHash::ToTree(int value, int direction)
{

}

void BinaryHash::printTree()
{

}

void BinaryHash::printHT(int value, int direction)
{

}

void BinaryHash::deleteNode(node *n)
{

}

binaryhash.h line 46 You need a forward declaration of the struct node . Or just move the private part before the public one. binaryhash.h line 46 void deleteNode(node *n) takes a pointer, not a value. binaryhash.h line 54 This one I don't really get, probably some spelling mistake or something.

Thank you, switching the private and public section around fixed all of the errors. Makes sense. Marked as solved.

commented: Glad to see someone polite ;P +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.