954,148 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

struct type redefinition

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

cscgal
The Queen of DaniWeb
Administrator
19,421 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
 
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(<strong>struct process, struct node*</strong>); // helper function for public insert()
public:
queue(); // constructor function
void insert(<strong>struct process</strong>);
void traverse(<strong>struct node*</strong>);
bool isEmpty();
};
subtronic
Junior Poster
117 posts since Aug 2003
Reputation Points: 44
Solved Threads: 1
 

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 but instead will only allow me #include

cscgal
The Queen of DaniWeb
Administrator
19,421 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
 
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 but instead will only allow me #include

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?

subtronic
Junior Poster
117 posts since Aug 2003
Reputation Points: 44
Solved Threads: 1
 

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.

cscgal
The Queen of DaniWeb
Administrator
19,421 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
 

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

cscgal
The Queen of DaniWeb
Administrator
19,421 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
 
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".

subtronic
Junior Poster
117 posts since Aug 2003
Reputation Points: 44
Solved Threads: 1
 

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

AJann
Newbie Poster
1 post since Sep 2003
Reputation Points: 11
Solved Threads: 0
 

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.

siphen
Newbie Poster
1 post since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

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...

Fbody
Posting Maven
2,930 posts since Oct 2009
Reputation Points: 833
Solved Threads: 393
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You