Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Could someone answer my questions on this LL Header?

Posted on 2001-06-20
8
Medium Priority
?
655 Views
Last Modified: 2006-11-17
I was hoping someone could answer my questions I posted for this LL header file.

I am not sure what this struct NodeType is for and why do you need it?
struct NodeType;

I am not sure what this line is doing?
typedef NodeType *NodePtr;

//Complete Declaration.
struct NodeType
{
int num2;
NodePtr link; Is link a pointer?
};
class List
{
public:
List(); //Constructor
~List(); //Destructor
bool Isempty() const;//Checks to see if Node is empty
void InsertAfter(int num);//Inserts the correct node value
void Delete(int num);//Deletes the correct Node value
void Print(ostream& Outfile) const;//Outputs the correct output
void Print1(ostream& Outfile) const;//Outputs the correct output

//private members of the class List.
private:

NodePtr head; I guess these are all pointers?
NodePtr tail;
NodePtr currptr;
NodePtr newNodeptr;
NodePtr searcher;
NodePtr trailer;

};

What exactly are the nodes?
0
Comment
Question by:awjackin35
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 3

Expert Comment

by:SEve
ID: 6211740
this link
http://swww.ee.uwa.edu.au/~plsd210/ds/lists.html
gives good picture about linked list, how it is built, what does it contain, what is "the node" and so on.
if you'll read it, i'm sure, you'll get answers to almost all of your questions.

good luck, seve

btw: link is a pointer to struct NodeType
0
 
LVL 4

Accepted Solution

by:
pluim earned 220 total points
ID: 6211761
Answers:
1. This is a forward declaration of NodeType. The actual declaration comes later. This is needed since the typedef statement uses NodeType. You need a structure because two data items need to be combined: the actual data (num2) and a pointer to the next element in the list (link).
Note that this is efficient but poor OO-programming. The structure NodeType should have been implemented as a class.

2. "NodePtr" is equivalent to "struct NodeType*". This aliasing could be done for a number of reasons. Most likely, the programmer thought "NodePtr" looked cleaner (or easier) than "struct NodeType*". It certainly is shorter.

3. Yes, link is a pointer. Its actual type is "struct NodeType*" (see 2). Or, in English, "Link is a pointer to a NodeType structure".

4. Yes, they are all pointers.

5. Each element in the list is a NodeType structure. These are the nodes. All the List class does is keep track of the last/ first/ current element, and offer some basic functions such as insert/ delete/ isEmpty. The actual data, as well as a pointer to the next element (node) is stored in a NodeType structure.
0
 
LVL 22

Expert Comment

by:nietod
ID: 6222863
Does anyone know if this accepted answer was posted as a comment or as an answer?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Expert Comment

by:SEve
ID: 6222871
i guess, pluim knows :-)
0
 
LVL 22

Expert Comment

by:nietod
ID: 6222894
If you haven't cleared your e-mail trash recently, you might be able to find the notification of pluim's post.  it will indicate if the post was a comment or answer.  (If you don't mind searching, that is.)
0
 
LVL 3

Expert Comment

by:SEve
ID: 6222940
i don't mind, but i don't keep this kind of messages for a long time. sorry

seve
0
 
LVL 22

Expert Comment

by:nietod
ID: 6228744
That's fine.

Anyone else know?  we're trying to measure the number of comments vs answers.
0
 

Author Comment

by:awjackin35
ID: 6229377
It was a comment
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question