delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/09/02/15:51:58

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Message-ID: <20040902195136.82456.qmail@web20226.mail.yahoo.com>
Date: Thu, 2 Sep 2004 12:51:36 -0700 (PDT)
From: pradyut bhattacharya <pradyut100 AT yahoo DOT com>
Subject: linked list problem
To: prgc AT yahoogroups DOT com, djgpp AT delorie DOT com
MIME-Version: 1.0

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)
*/

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

any help

thanks

Pradyut
http://pradyut.tk

India

=====



		
__________________________________
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019