ADT.h

struct process
{
	int pid; // process id
	char* file_name; // file name of the process to be run
	int cpu_time; // amount of time the process needs with the cpu
	int request_priority; // priority from 1-5 (higher is better)
	int pr; // adjusted priority rate
};

/**********************************************************************/
/***** A NODE OF OUR BINARY TREE
/**********************************************************************/

struct node
{
	process key;

	// pointers to child nodes
	node *left;
	node *right;
};

/**********************************************************************/
/***** ADT PRIORITY QUEUE HEAP STRUCTURE (BINARY TREE)
/**********************************************************************/

class queue
{
	node* root;
	void insert(process, node*); // helper function for public insert()

public:
	queue(); // constructor function
	void insert(process);
	void traverse(node*);
	bool isEmpty();
};

Why am I getting errors:
'process' : 'struct' type redefinition
'node' : 'struct' type redefinition
'queue' : 'class' type redefinition

Why am I getting errors:
'process' : 'struct' type redefinition
'node' : 'struct' type redefinition
'queue' : 'class' type redefinition

My first guess is you're using Visual C++ :) It compiles fine with g++, maybe try:

struct process
{
int pid; // process id
char* file_name; // file name of the process to be run
int cpu_time; // amount of time the process needs with the cpu
int request_priority; // priority from 1-5 (higher is better)
int pr; // adjusted priority rate
};
/**************************************************  ********************/
/***** A NODE OF OUR BINARY TREE
/**************************************************  ********************/
struct node
{
process key;
// pointers to child nodes
node *left;
node *right;
};
/**************************************************  ********************/
/***** ADT PRIORITY QUEUE HEAP STRUCTURE (BINARY TREE)
/**************************************************  ********************/
class queue
{
node* root;
void insert([B]struct process, struct node*[/B]); // helper function for public insert()
public:
queue(); // constructor function
void insert([B]struct process[/B]);
void traverse([B]struct node*[/B]);
bool isEmpty();
};

Edited 6 Years Ago by Nick Evan: n/a

Grr do I hate this! All these days playing around and finally I figured out my problem. Visual C++ seems to have a problem with #include<iostream.h> but instead will only allow me #include<iostream>

Grr do I hate this! All these days playing around and finally I figured out my problem. Visual C++ seems to have a problem with #include<iostream.h> but instead will only allow me #include<iostream>

Oh I guess that makes sense. The last time I used g++ 3.something it yelled at me about those header files being deprecated. I take it you're programming for a class? I though most universities were phasing C++ out for Java?

Yeah, it's for a class. My professor only cares about the algorithm, not the language. You can write in C, C++, or Java, whichever you're most comfortable in.

If anyone's curious, this is the same program as is discussed here: [thread]938[/thread]

If anyone's curious, this is the same program as is discussed here: [thread]938[/thread]

Do you still need help with this homework? I take it you're programming a heap and using heap sort to implement the priority queue? Can you choose any stradegy for sending/storing to a queue; there's a couple good ways of multiplexing your "processor".

This type of error may happpen if your header called/included more than once. This happens :)). So, try to precede and end you header like that:

#ifndef __yourheader_h
#define __yourheader_h (1)

// Put here the body of your ".h" file including the class


#endif

This type of error may happpen if your header called/included more than once. This happens :)). So, try to precede and end you header like that:

#ifndef __yourheader_h
#define __yourheader_h (1)

// Put here the body of your ".h" file including the class


#endif

Thanks AJann, that sorted out my problem.

Umm.... this thread is 7 years old. Why did you res it just to say thanks to someone that wasn't even talking to you?

An unfortunate waste of a first post...

This article has been dead for over six months. Start a new discussion instead.