struct type redefinition

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2002
Posts: 12,041
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 129
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

struct type redefinition

 
0
  #1
Aug 23rd, 2003
ADT.h

  1. struct process
  2. {
  3. int pid; // process id
  4. char* file_name; // file name of the process to be run
  5. int cpu_time; // amount of time the process needs with the cpu
  6. int request_priority; // priority from 1-5 (higher is better)
  7. int pr; // adjusted priority rate
  8. };
  9.  
  10. /**********************************************************************/
  11. /***** A NODE OF OUR BINARY TREE
  12. /**********************************************************************/
  13.  
  14. struct node
  15. {
  16. process key;
  17.  
  18. // pointers to child nodes
  19. node *left;
  20. node *right;
  21. };
  22.  
  23. /**********************************************************************/
  24. /***** ADT PRIORITY QUEUE HEAP STRUCTURE (BINARY TREE)
  25. /**********************************************************************/
  26.  
  27. class queue
  28. {
  29. node* root;
  30. void insert(process, node*); // helper function for public insert()
  31.  
  32. public:
  33. queue(); // constructor function
  34. void insert(process);
  35. void traverse(node*);
  36. bool isEmpty();
  37. };

Why am I getting errors:
'process' : 'struct' type redefinition
'node' : 'struct' type redefinition
'queue' : 'class' type redefinition
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Aug 2003
Posts: 117
Reputation: subtronic is an unknown quantity at this point 
Solved Threads: 1
subtronic's Avatar
subtronic subtronic is offline Offline
Junior Poster

Re: struct type redefinition

 
2
  #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 Quick reply to this message  
Join Date: Feb 2002
Posts: 12,041
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 129
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb
 
0
  #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>
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Aug 2003
Posts: 117
Reputation: subtronic is an unknown quantity at this point 
Solved Threads: 1
subtronic's Avatar
subtronic subtronic is offline Offline
Junior Poster

Re: struct type redefinition

 
0
  #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 Quick reply to this message  
Join Date: Feb 2002
Posts: 12,041
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 129
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

Re: struct type redefinition

 
0
  #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.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,041
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 129
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

Re: struct type redefinition

 
0
  #6
Aug 26th, 2003
If anyone's curious, this is the same program as is discussed here: http://www.daniweb.com/forums/thread938.html
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Aug 2003
Posts: 117
Reputation: subtronic is an unknown quantity at this point 
Solved Threads: 1
subtronic's Avatar
subtronic subtronic is offline Offline
Junior Poster

Re: Re: struct type redefinition

 
0
  #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 Quick reply to this message  
Join Date: Sep 2003
Posts: 1
Reputation: AJann is an unknown quantity at this point 
Solved Threads: 0
AJann AJann is offline Offline
Newbie Poster

Re: struct type redefinition

 
1
  #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 Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC