What is problem with below class

Posted by user258367 on Stack Overflow See other posts from Stack Overflow or by user258367
Published on 2010-03-22T06:57:14Z Indexed on 2010/03/22 7:01 UTC
Read the original article Hit count: 193

Filed under:
class LinkedList
{
  private:
    int data;  
    LinkedList *ptr;  
public:
  LinkedList(int i_data)  
  { 
    data = i_data;  
    ptr = 0;  
  {  
  ~LinkedList()  
  {  
    delete ptr ;  
  }  
  void insert(LinkedList *node)  
  {  
    while(this->next != 0)  
    this = this->next;  

    this->next = node;  
  }  

I will be creating a head node like head = new LinkedList(4) and then will be calling like head->insert(new LinkedList(5)) and subsequently . Can you please tell me does above class represent a linkedlist . i think yes it has node which contain address of next node . Please correct me if i am wrong

© Stack Overflow or respective owner

Related posts about c++