I'm making a red black tree (RedBlack class) whose nodes will contain customers (customer class) rather than the generic int data. Unfortunately, I can't seem to get VS 2008 Express recognize that data is of type customer. I get all sorts of redefinition errors, and I've tried pragma once and include guards to no avail.
//HEADER for customer class//
#include <string>
using namespace std;
class customer
{
public:
customer();
customer(string last, char first, int balance);
void set_account(int balance);
string get_name();
char get_initial();
int get_account();
~customer(void);
private:
string name;//customer's last name
char initial;//customer's first initial
int account;//balance owed by customer
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//CPP FILE for customer class
#include "StdAfx.h"
#include "customer.h"
customer::customer(){
}
customer::customer(string last, char first, int balance)
{
name = last;
initial = first;
account = balance;
}
void customer::set_account(int balance){
account = balance;
}
string customer::get_name(){
return name;
}
char customer::get_initial(){
return initial;
}
int customer::get_account(){
return account;
}
customer::~customer(void)
{
}
//HEADER
#pragma once
//#ifndef CUSTOMER_H
//#define CUSTOMER_H
#include "customer.h"
class RedBlack
{
private:
struct node {
bool red; //True if red, False if black
int data; //customer data
struct node *next[2]; //pointer to an array where index 0 is left and index 1 is right
};
node *root;
customer data;
struct tree{
struct node *root;//pointer to the root
};
public:
RedBlack();
bool isRed(struct node *root);
~RedBlack(void);
//#endif
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//CPP
#include "StdAfx.h"
//#ifndef CUSTOMER_HPP
//#define CUSTOMER_HPP
#include "RedBlack.h"
RedBlack::RedBlack()
{
root = NULL;
}
bool RedBlack::isRed(struct node *root){
if (root != NULL && root->red == true)
return true;
}
RedBlack::~RedBlack(void)
{
}
//#endif
};
Any help would be much appreciated