I've been trying to work it out for more than 10 hours already and still can get pass this
The basic skeleton is like this

class BST
{
public:
....
void insert (const device & aDevice);
.....
private:
.....
};

class device : public BST
{
.....
};

Then keep getting an error that say that ran
"error C2504: 'BST' : base class undefined" on the class device : public BST
"error C4430: missing type specifier - int assumed. Note: C++ does not support default-int" on the insert function
Can any one help? I've really new to inheritance

What is 'device' supposed to be? I don't think you should be using inheritance for this problem. It's very weird to see the base class receiving the child class as an argument, especially to insert.

There's no hope of getting real help if you don't paste real code. You probably need to predeclare some class, to get it to compile, but your code is still probably messed up.

What i'm trying to make is a BST for each of the derived class of "device" and linked list any object that has the same feature

struct node
{
	device item;
	node * next, * left, * right;

	node(const device& aDevice)
	{
		item = aDevice;
		next = left = right = NULL;
		
	}
};
//////////////////////////////////////////////////////////////////////////////////////////////////////
class list 
{
public :
	list();
	list(const list& aList);
	~list();

	const list& operator= (const list& aList);

	virtual void insert(const device& aDevice);

protected:
	
	int size;
	node * head;

	void destroyList();	
}

//////////////////////////////////////////////////////////////////////////////////////////////////////
class BST : public list
{
public:
	BST();
	BST(const BST& aTree);			
	~BST();						

	const BST& operator= (const BST& aTree);	
	
	void insert(const device& aDevice);			
	bool remove(char * key);						
	bool retrieve(char * key, device& aDevice)const;

protected:
	node* root;						
		
		void insert(node*& root, const device& aDevice);
		bool retrieve(node * root, char * key, device& aDevice) const;
		bool remove(node*& root, char * key);
		void deleteNode(node *& target);
		void destroyTree(node*& root);
		void copyTree(node*& newRoot, node * root);

}

//////////////////////////////////////////////////////////////////////////////////////////////////////
class device : public BST
{
public:
	friend ostream& operator<< (ostream& out, const device& aDevice);
	device();
	device(char * name, char * type);
	device(const device& aDevice);		
	~device();						

	const device& operator=(const device& adevice);	//overloading assignment operator

	void getName(char * name)const;
	void getType(char * type)const;
	float getPrice(void)const;

	void setName(char * name);
	void setType(char * type);
	void setPrice(float price);
	
protected:
	char * name;
	char * type;
	float price;
};

//////////////////////////////////////////////////////////////////////////////////////////////////////
class cellphone: public device
{
public:
	computer();
	computer(char * name, char * type, char * frequency, bool touchscreen);
	computer(const device& aDevice, char * frequency, bool touchscreen);		
	~device();

	getFrequency(.....);
	get............;


protected:
	char * frequency;
	bool QWERTY;

}
//////////////////////////////////////////////////////////////////////////////////////////////////////
class mp3player : public device
{
public:
	........................
protected:
	........................
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
and a few more classes derived from "device"

The object of class computer and cellphone are what need to be in the BSTs. By this design, I expect that each class derived from "device" will has there own BST.

And the object that have the same capability would be link together such as any device that has touch screen need to be in a Linear Linked List (be it cell phone or mp3player) and all devices that can take photo need to be in another linked list.

I've tried alot, but my the design and implement aren't going well. Any hint and suggestion is great.

to solve the compilation error u have to forward the declaration of class device. That means simply add a

class device;

before you declare BST
good luck

Hi,

to solve the compilation error u have to forward the declaration of class device. That means simply add a
Help with Code Tags
(Toggle Plain Text)

class device;

class device;
before you declare BST
good luck

mmmmm....yes it might compile now, however....

based on your description u defined the relationships between the classes the following way:

An mp3player is-a device ->Inheritance I AGREE
A cellphone is-a devide -> Inheritance I AGREE
A list owns-a node ->Aggregation I AGREE
A BST is-a list ->Inheritance mmm I kind of agree...
U could also use:
A BST has-a list ->Composition


A device is-a BST -> Inheritance I DISAGREE

My opinion is that this last definition is wrong.

I would like to remind that:
A BST (binary search tree) is special kind of binary tree used to store information in an ordered way. So how can h define a device object to be BST object... :D :D

Have a look on my two posts here:
http://www.daniweb.com/forums/thread152154.html

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.