Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

linked lists problem

  Asked By: Mali    Date: Sep 10    Category: Java    Views: 1125
  

i'm using rhidew compiler in winxp

the program

----------------------------------------------

#include <iostream>
#include <string>

using namespace std;

struct Node
{
string name;
Node *NEXT;
Node (const string &s, Node * n = NULL): name
(s), NEXT (n)
{
}
};

class List
{
private:
Node *START,
*CURRENT,
*PRECEDE;
public:
List()
{
START = CURRENT=PRECEDE=NULL;
}
~List()
{
destroy();
}
void addNode(const string &s)
{
if (START == NULL || s <==START->name)
{
START = new Node(s, START);
return;
}
Node *prev, *curr;
for (prev = curr = START; curr !=NULL && s >
curr->INFO; prev = curr, curr = curr->NEXT)
{
}
Node *n = new Node (s, curr);
prev->NEXT = n;
}
void destroy
{
while(START!= NULL)
{
CURRENT = START;
START = START->NEXT;
delete CURRENT;
}
START = PRECEDE = CURRENT = NULL;
}
};

int main()
{
List obj;
String s;
getline(cin, s);
obj.addNode(s);
}
-------------------------------------------------

the error on gpp compiler

/*
string.cc:45: error: invalid member function
declaration
string.cc: In destructor `List::~List()':
string.cc:28: error: `destroy' undeclared (first use
this function)
string.cc:28: error: (Each undeclared identifier is
reported only once for each
function it appears in.)
string.cc: In member function `void
List::addNode(const std::string&)':
string.cc:32: error: expected primary-expression
before '=' token
string.cc:32: error: 'struct Node' has no member named
'NAME'
string.cc:38: error: 'struct Node' has no member named
'INFO'
string.cc:42: error: `Prev' undeclared (first use this
function)
string.cc: In function `int main()':
string.cc:59: error: `String' undeclared (first use
this function)
string.cc:59: error: expected `;' before "s"
string.cc:60: error: `s' undeclared (first use this
function)
*/

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on linked lists problem Or get search suggestion and latest updates.




Tagged: