found a solution to my problem.
i will just have to seperate my classes and after creating each object, i will have to call the bst.add() funciton
bst.add(a)
bst.add(b)
bst.add(c)
Edit: I already tried it and i couldn't get it to work.
Her is what i tried
Here is my btree class prototype
Code:
#ifndef DATA_H_
#define DATA_H_
#include <iostream>
struct node
{
int ID;
char * pName;
char * pSup;
int pCost;
int pDays;
node * left;
node * right;
};
class btree {
public:
btree();
~btree();
void insert(char[], char[], int, int);
int removeProj(char[]);
bool search( char *name, char *sup, int &, int &);
void destroy_tree();
void displayall();
private:
void destroy_tree(node *leaf);
void insert(node *curr, node *leaf);
node *search(char name[], node *leaf);
void print_inorder(node *p);
void removeLeaf(char name[], node* pleaf, node *leaf);
node *root;
};
#endif
Here is my class inherency
Code:
#ifndef DEVICE_H_
#define DEVICE_H_
#include <iostream>
#include "data.h"
/* Devices Base Class
-----------------------------------------------------------------------------------*/
class device {
public:
device(char * l);
void service();
void showOutput();
void showStatus();
void display();
private:
static btree b;
};
class smart : public device
{
};
class power : public device
{
};
#endif
functions for these classes
#include <iostream>
#include <iomanip>
#include "device.h"
using namespace std;
device::device(char * l)
{
b.insert(l, l, 0, 0);
}
void device::display()
{
b.displayall();
}
here is main
Code:
#include "data.h"
#include "device.h"
using namespace std;
int main()
{
device a("TV");
device b("CELL");
device c("phone");
c.display();
return 0;
}
here is the error i get
Code:
AMXPROv2:P1 dodo$ g++ data.cpp device.cpp main.cpp
Undefined symbols:
"btree::root", referenced from:
__ZN5btree4rootE$non_lazy_ptr in ccLJe3HQ.o
"device::b", referenced from:
__ZN6device1bE$non_lazy_ptr in ccs8GENf.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
AMXPROv2:P1 dodo$