What's the proper approach to having my node data being a class object?
//RedBlack.h
class RedBlack
{
public:
RedBlack(void);
~RedBlack(void);
private:
struct Node {
customer data; //list data
Node *next; //pointer to next item in the list
};
Node *head; //Pointer to the first node in the list
int size; //Records the number of nodes in the list
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//RedBlack.cpp
#include "StdAfx.h"
#include "RedBlack.h"
#include "customer.h"
RedBlack::RedBlack(void)
{
}
RedBlack::~RedBlack(void)
{
}
//customer.h
#include <string>
using namespace std;
class customer
{
public:
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
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//customer.cpp
#include "StdAfx.h"
#include "customer.h"
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)
{
}

New Topic/Question
Reply
MultiQuote







|