943,262 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 30199
  • C++ RSS
Aug 23rd, 2003
0

struct type redefinition

Expand Post »
ADT.h

C++ Syntax (Toggle Plain Text)
  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
Similar Threads
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is online now Online
13,645 posts
since Feb 2002
Aug 23rd, 2003
2

Re: struct type redefinition

Quote 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();
};
Last edited by Nick Evan; Feb 4th, 2010 at 5:04 pm.
Reputation Points: 44
Solved Threads: 1
Junior Poster
subtronic is offline Offline
117 posts
since Aug 2003
Aug 26th, 2003
0
Re: struct type redefinition
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>
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is online now Online
13,645 posts
since Feb 2002
Aug 26th, 2003
0

Re: struct type redefinition

Quote 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?
Reputation Points: 44
Solved Threads: 1
Junior Poster
subtronic is offline Offline
117 posts
since Aug 2003
Aug 26th, 2003
0

Re: struct type redefinition

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.
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is online now Online
13,645 posts
since Feb 2002
Aug 26th, 2003
0

Re: struct type redefinition

If anyone's curious, this is the same program as is discussed here: http://www.daniweb.com/forums/showthread.php?t=938
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is online now Online
13,645 posts
since Feb 2002
Aug 26th, 2003
0

Re: Re: struct type redefinition

Quote originally posted by cscgal ...
If anyone's curious, this is the same program as is discussed here: http://www.daniweb.com/forums/showthread.php?t=938
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.
Reputation Points: 44
Solved Threads: 1
Junior Poster
subtronic is offline Offline
117 posts
since Aug 2003
Sep 3rd, 2003
2

Re: struct type redefinition

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
Reputation Points: 11
Solved Threads: 0
Newbie Poster
AJann is offline Offline
1 posts
since Sep 2003
Feb 4th, 2010
-3
Re: struct type redefinition
Click to Expand / Collapse  Quote originally posted by AJann ...
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
siphen is offline Offline
1 posts
since Feb 2010
Feb 4th, 2010
2
Re: struct type redefinition
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...
Featured Poster
Reputation Points: 833
Solved Threads: 392
Posting Maven
Fbody is offline Offline
2,846 posts
since Oct 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Binary trees
Next Thread in C++ Forum Timeline: strcpy() and strncpy()





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC