--- Pradeep Maddineni <[EMAIL PROTECTED]>
wrote:
> Hi, this is Pradeep, I just tried to write a linked
> list program in c++, here is my entire code. When i
> tried to execute it in Dev C++ I am getting a window
> which states that "mylinkedlist.exe has encountered
> a problem and needs to close. We are sorry for the
> inconvenience." and it is asking for " Send Error
> Report" or "Don't Send". I was wondering if anyone
> one figure it out the actual problem with it. I am
> really really suffered alot for this.
>
>
> //mylinkedlist.cpp
>
> #include <iostream>
> using namespace std;
>
> typedef struct Node{
>
> public:
> Node(int data){
> this->data = data;
> previous = NULL;
> next = NULL;
> }
> int data;
> struct Node* previous;
> struct Node* next;
> }NODE;
> class mylinkedlist{
>
> NODE* front;
> NODE* back;
> public:
> mylinkedlist();
> //~mylinkedlist();
> void appendNode(int data1);
> int deleteNode();
> // void traverseFront();
> // void traverseBack();
> //void destroyList();
> };
>
> mylinkedlist::mylinkedlist()
> {
> front = NULL;
> back = NULL;
> }
> /*mylinkedlist::~mylinkedlist(){
> destroylist();
> }*/
> void mylinkedlist::appendNode(int listdata)
> {
> Node* mynode = new Node(listdata);
> if(back == NULL)
> {
> back = mynode;
> front = mynode;
> }
> else
> {
> back->next = mynode;
> mynode->previous = back;
> back = mynode;
> }
> }
> int mylinkedlist::deleteNode()
> {
> cout<<"This is the data in the last node
> which is going to be deleted"<<back->data<<endl;
> if(back== NULL)
> {
> cout<<" Our Linked list is Empty";
> }
> else
> {
> Node *mynode;
> mynode = back;
> back = back->previous;
> back->next = NULL;
>
> }
> return 0;
> }
>
>
>
> int main()
> {
> mylinkedlist myllist;
> myllist.appendNode(10);
> myllist.appendNode(20);
> myllist.appendNode(30);
> myllist.deleteNode();
> myllist.deleteNode();
> myllist.deleteNode();
> myllist.deleteNode();
>
> return 0;
> }
>
>
>
> Thanks in advance..
>
> Pradeep.M
Check the logic in deleteNode(). It will fail with the
currentg logic. You are trying to work with a
NULL value
Mickey M.
Construction Partner Inc.
http://www.constructionpartner.com
____________________________________________________________________________________
The fish are biting.
Get more visitors on your site using Yahoo! Search Marketing.
http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php