GIDForums  

Go Back   GIDForums > Computer Programming Forums > CPP / C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 29-Nov-2004, 16:32
wbsquared03 wbsquared03 is offline
New Member
 
Join Date: Oct 2004
Posts: 14
wbsquared03 is on a distinguished road

help with delete function using pointers!!!


i need help with creating a delete function for my program, im getting really confused. Much help would be appreciated. THis program is due tomorrow. We have to use pointers and i get so confused. All other function written i have work but i can't get the delete function. Its very confusing for me. THanks in advance

CPP / C++ / C Code:
struct NodeType		//doubly linked list
{
	string word;
	int freq;
	NodeType* prev;
	NodeType* next;
};

class SortedType
{
public:
	SortedType();
	bool IsEmpty() const;
	int LengthIs() const;
	void FindItem(string& word, int& freq, bool& found);
	void InsertFirst(string newword);
	void InsertItemAfter(string newword);
	void IncFreq();
	void DeleteItem(string word, int& freq);
	void ResetList();
	void GetNextItem(string& word, int& freq, bool& moreNode);
	void Print();
private:
	NodeType *listData;
	int length;
	NodeType* currentPos;
};

void SortedType::InsertItemAfter(string newword)
{
	NodeType* newNode;
	NodeType* cpos;
	
	newNode=new NodeType;
	newNode->word=newword;
	newNode->freq=1;

	if(currentPos!=NULL)						//case II and III
	{
		newNode->prev=currentPos;
		newNode->next=currentPos->next;

		if(currentPos->next!=NULL)				//case II
			currentPos->next->prev=newNode;
		
		currentPos->next=newNode;
	}
	else										//case I
	{
		newNode->prev=NULL;
		newNode->next=listData;
		listData->prev=newNode;
		listData=newNode;
	}
	length++;
}

void SortedType::DeleteItem(string word, int& freq)
{
      //need help creating this function
}
 

Recent GIDBlog2nd Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] Doubly-linked List dsmith C Programming Language 6 14-Apr-2006 13:12
How to interpret characters as they are being entered? nkhambal C Programming Language 18 14-Feb-2006 10:41
Nested for loop with function Tori CPP / C++ Forum 11 08-Nov-2004 13:02
Revising Script style ?????? pepee MySQL / PHP Forum 4 14-Apr-2004 04:59

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 22:52.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.