Explore BrainMass
Share

Simple linked list C++

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

When I typical write a linked list class to store int values I would setup the class something like this....
struct Node {
int _item;
Node *_next;
};
Node *_head;

However, I know have to write a program that will use IntNode.h to create a linked list implementation.

The way the designer setup this .h file is confusing me and have been unable to create the implementation cpp file.

Can someone review my IntNode.cpp and guide me on how to code the correct implementation ? No major changes can be made to the .h file.

The tester for the class would be a very simple program:
#include <iostream>
#include <string>
#include "IntNode.h"

int main()
Node NL;
NL = Node(1);

//add values
NL.info(8);
NL.info(7);
NL.info(6);
...
//display values
...
return(0);
}

© BrainMass Inc. brainmass.com October 24, 2018, 9:12 pm ad1c9bdddf
https://brainmass.com/computer-science/cpp/simple-linked-list-c-119906

Attachments

Solution Preview

The basic trick here is to use one more class. There are many different ways of doing this.

1. You can define a class List and a private class Node inside the class List.
2. You can define the two classes and declare that one ...

Solution Summary

Simple linked list C++ is devised.

$2.19
See Also This Related BrainMass Solution

C++ Functions to Perform Basic Linked List Operations

Write the functions (in C++) to perform these basic operations on Linked List:

1. To determine whether the list is empty.
2. To find the length of the list.
3. To retrieve the information contained in the first node.
4. To search the list for a given item.
5. To make a copy of the linked list.

View Full Posting Details