?
Solved

typedef  PtrToNode List; program defined List implementation

Posted on 2003-03-18
5
Medium Priority
?
526 Views
Last Modified: 2008-02-01
error C2146: syntax error : missing ';' before identifier 'List'

typedef struct Node *PtrNode;
typedef PtrToNode List; //my error is in this part
typedef PtrToNode Position;

struct Node
{
     ElementType Element;
     Position Next;
};

//function declarations
List MakeEmpty(List L);
int IsEmpty(List L);
int IsLast(Position P, List L);
Position Find( ElementType X, List L);
void Delete(ElementType X, List L);
Position FindPrevious(ElementType X, List L);
void Insert(ElementType X, List L, Position P);
void DeleteList(List L);
Position Header(List L);
Position First(List L);
Position Advance(Position P);
ElementType Retrieve(Position P);
0
Comment
Question by:crazyMonkey
[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
  • 2
  • 2
5 Comments
 
LVL 15

Expert Comment

by:efn
ID: 8161469
The compiler doesn't know what PtrToNode is.

I think you want the first typedef to define "PtrToNode", not "PtrNode".
0
 
LVL 30

Accepted Solution

by:
Mayank S earned 120 total points
ID: 8164564
>> typedef struct Node *PtrNode;

You cannot type-define a structure like this. Please remove the '*' before PtrNode.

I think what you want to do might be achieved by this:

typedef struct Node
{
    ElementType Element ;
    Node * Next ;
} List ;

Or:

struct Node
{
    ElementType Element ;
    Position * Next ;
} ;

typedef Node List ;

Also that: you need to define struct Node first before specifying a type-defined name for it.

Mayank.
0
 
LVL 9

Expert Comment

by:tinchos
ID: 9510526
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by: mayankeagle

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0
 
LVL 15

Expert Comment

by:efn
ID: 9510649
With all due respect, I think my answer was better.

From the information available, crazyMonkey's problem was just defining PtrNode and then trying to refer to it with the different name PtrToNode.

With that correction, the design is OK and does not need the changes mayankeagle suggested.

--efn
0
 
LVL 9

Expert Comment

by:tinchos
ID: 9510664
Sorry efn, I know your comment is correct,
but I felt that with your comment crazyMonkey would not have been able to solve his problem.
I think mayankeagle's comment summaryses all the modifications needed.

Anyway, its just my opinion and my recommendation is not final as the moderator will check it out before closing it.
0

Featured Post

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.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

771 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