I am getting segmentation fault - WHY?

Discussion in 'Software' started by bhavinvyas, Dec 31, 2008.

  1. bhavinvyas

    bhavinvyas

    Joined:
    Dec 31, 2008
    Messages:
    1
    Location:
    mumbai
    template<class T>
    void List<T>::push(T s)
    {
    Node<T>* newnode = new Node<T>(s);
    if (last == NULL) /* list is empty */
    {
    first = newnode;
    last = newnode;
    count++;
    }
    else
    {
    newnode->previous = last;
    last->next = newnode;
    last = newnode;
    count++;
    }
    };

    When i compile it compiles properly but when i run/execute a.out it gives me segmentation fault in this what could be the possible cause. Does any one knows the answer. please let me know.
     
    bhavinvyas, Dec 31, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Keith Lee
    Replies:
    3
    Views:
    2,537
    Grzegorz Karwowski
    Apr 29, 2006
  2. deltaone

    Segmentation Fault in C++

    deltaone, Aug 2, 2006, in forum: Software
    Replies:
    0
    Views:
    1,276
    deltaone
    Aug 2, 2006
  3. sakura

    Segmentation fault in C (fclose)

    sakura, Aug 31, 2006, in forum: Software
    Replies:
    1
    Views:
    1,536
    Alain
    Oct 20, 2006
  4. acumind@gmail.com

    Segmentation fault in 'accept'

    acumind@gmail.com, Aug 16, 2007, in forum: Computer Support
    Replies:
    0
    Views:
    925
    acumind@gmail.com
    Aug 16, 2007
  5. Peter Potamus the Purple Hippo

    Re: Segmentation Fault

    Peter Potamus the Purple Hippo, Nov 29, 2009, in forum: Firefox
    Replies:
    3
    Views:
    1,680
    Leonidas Jones
    Dec 2, 2009
Loading...

Share This Page