User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 456,485 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,780 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 15406 | Replies: 7
Reply
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 11,019
Reputation: cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice 
Rep Power: 33
Solved Threads: 116
Admin
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

Help struct type redefinition

  #1  
Aug 23rd, 2003
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2003
Location: Austin, TX
Posts: 117
Reputation: subtronic is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 1
subtronic's Avatar
subtronic subtronic is offline Offline
Junior Poster

Re: struct type redefinition

  #2  
Aug 23rd, 2003
Originally Posted by cscgal
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(struct process, struct node*); // helper function for public insert()
public:
queue(); // constructor function
void insert(struct process);
void traverse(struct node*);
bool isEmpty();
};
Reply With Quote  
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 11,019
Reputation: cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice 
Rep Power: 33
Solved Threads: 116
Admin
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb
  #3  
Aug 26th, 2003
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>
Reply With Quote  
Join Date: Aug 2003
Location: Austin, TX
Posts: 117
Reputation: subtronic is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 1
subtronic's Avatar
subtronic subtronic is offline Offline
Junior Poster

Re: struct type redefinition

  #4  
Aug 26th, 2003
Originally Posted by cscgal
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?
Reply With Quote  
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 11,019
Reputation: cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice 
Rep Power: 33
Solved Threads: 116
Admin
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

Re: struct type redefinition

  #5  
Aug 26th, 2003
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.
Reply With Quote  
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 11,019
Reputation: cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice 
Rep Power: 33
Solved Threads: 116
Admin
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

Re: struct type redefinition

  #6  
Aug 26th, 2003
If anyone's curious, this is the same program as is discussed here: http://www.daniweb.com/forums/thread938.html
Reply With Quote  
Join Date: Aug 2003
Location: Austin, TX
Posts: 117
Reputation: subtronic is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 1
subtronic's Avatar
subtronic subtronic is offline Offline
Junior Poster

Re: Re: struct type redefinition

  #7  
Aug 26th, 2003
Originally Posted by cscgal
If anyone's curious, this is the same program as is discussed here: http://www.daniweb.com/forums/thread938.html

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".
Last edited by subtronic : Aug 26th, 2003 at 1:13 pm.
Reply With Quote  
Join Date: Sep 2003
Posts: 1
Reputation: AJann is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
AJann AJann is offline Offline
Newbie Poster

Solution Re: struct type redefinition

  #8  
Sep 3rd, 2003
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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 3:03 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC