Register | Sing In

New posts

Stacks in C programming Linked Lists in C programming File Input/Output in C programming Check prime numbers in C Programming C Programming Enumeration C Programming Union

Archives

2013-10 2013-09 2013-08

Linked list c++

June 18, 2014 Posted by: abrahim Views: 485

 In the private data of the Node class put two pointers: One with type Node * and name next, which will point to the next node in the linked list,The second with type Car* and name data, which will point to the Car data associated with this node.Also in the private area create a default constructor that sets the next and data pointers to zero.

In the public area of the Node class, make StringOfCars a friend class.

Declare the StringOfCars class with:   class StringOfCars; 

The Node class 

The StringOfCars class 

Rebuild the push function, with the same function heading. Declare a local pointer variable of type Car * named currentCarPtr. Declare a local pointer variable of type Node * named currentNodePtr. Use new to get space in the heap for a Node and save the address of the space in the heap in currentNodePtr 

 new Node object to point to the new Car object. If the head pointer is zero   set the head and the tail pointer to the value of currentNodePtr else   set the next pointer of the Node object pointed to by the tail pointer to the value of   currentNodePtr   set the next pointer to the value of the  currentNodePtr 

if the head pointer is zero   print: NO cars else   set the currentNodePointer to the value of the head pointer   while the currentNodePointer is not zero       print the Car pointed to by the currentNodePointer       set the currentNodePtr to the next pointer in the Node pointed to by       the currentNodePtr, which now makes the next Node the current Node 

Best Answer

No answer

Online Chat

LiveZilla Live Help

Popular posts

Function strtok in C programming Check prime numbers in C Programming C Programming Union Linked Lists in C programming File Input/Output in C programming C Programming Enumeration

RSS-subscribe

New materials

Subscribe