I want to write several functions so that the program below would work.
I am trying to find the functions for the main routine provided below and reveal a secret message. I dont wanne make any changes to the main routine. I just want to write all the functions, but I cant. is there any one here who could help me with that?
Thanks - #include <iostream>
-
#include <string>
-
using namespace std;
-
#include "list.cpp"
-
-
-
int main() {
-
LinkedList<string> rebelList1(4," ");
-
Iterator<string> iter1 = rebelList1.end();
-
iter1.backward();
-
rebelList1.erase(iter1);
-
iter1.backward();
-
rebelList1.insert(iter1,"Co");
-
iter1.forward();
-
rebelList1.insert(iter1,"it");
-
rebelList1.insert(iter1, rebelList1[2]);
-
rebelList1[0] = "ldth\nha";
-
rebelList1.pop_back();
-
rebelList1.push_back("all");
-
rebelList1.push_front("oth\nb");
-
-
LinkedList<string> rebelList2;
-
rebelList2.push_back("Tatooine");
-
rebelList2.push_front("Lando");
-
rebelList2.push_back(" sh");
-
rebelList2.pop_front();
-
rebelList2.pop_front();
-
rebelList2.push_front("hey");
-
rebelList2.reverse();
-
Iterator<string> iter2 = rebelList2.find(" sh");
-
rebelList2.insert(iter2,"ou");
-
rebelList2.reverse();
-
iter2 = rebelList2.find("hey");
-
rebelList2.insert(iter2,"oth\nb");
-
iter2.backward();
-
rebelList2.insert(iter2,"n H");
-
rebelList2.reverse();
-
rebelList2.insert(iter2,"ut t");
-
rebelList2.push_front("ld c");
-
-
LinkedList<string> rebelList3;
-
rebelList3.push_front("bel b");
-
rebelList3.push_back("e");
-
Iterator<string> iter3 = rebelList3.find("e");
-
rebelList3.insert(iter3, "re");
-
rebelList3.reverse();
-
rebelList3.insert(iter3, "th");
-
rebelList3.push_back("a");
-
iter3.forward();
-
rebelList3.insert(iter3, " ");
-
-
LinkedList<string> rebelList4 = rebelList3;
-
rebelList4[0] = "y, Da";
-
rebelList4[3] = "nes";
-
rebelList4.reverse();
-
rebelList4[1] = "lenti";
-
rebelList4.push_back("rt");
-
rebelList4.push_front("y v");
-
rebelList4.reverse();
-
rebelList4[2] = "da";
-
-
LinkedList<string> rebelList = rebelList1 + rebelList2;
-
rebelList = rebelList4 + rebelList;
-
rebelList.push_front("h!\n");
-
LinkedList<string> oneWord(1,"s o");
-
rebelList = rebelList + oneWord;
-
rebelList[9] = "pp";
-
rebelList.reverse();
-
rebelList.push_front("se i");
-
rebelList = rebelList3 + rebelList;
-
-
rebelList.print();
-
-
return 0;
-
}
6 3943
You'll need to look up template classes and template programming. Here is a tutorial on them. Other than that, if you don't really know how linked lists work, go to Wikipedia or Google and get the information there and implement first without templates, then add them.
THIS IS MY list.h file that I made, which is not complete
abd below that I have my list.cpp, which is the functions, but its not compete, is there any one here who can complete it?
thanks
First off, we're not going to do your work for you. Also, please use the provided CODE tags so that your code is formatted for easy reading.
Where precisely are you having your problem(s)? Let us know what error messages you get/what the output is that it shouldn't be.
Why are you using C++ to write a linked list when the standard library list template is already written???????
Is this an academic exercise??
just I like to learn C++ as a hobby
by the way I wrote the program
thanks
The danger in doing something like this is your time investment. If this becomes your creation you will use it on a real job and interject more non-standard C++ software into the industry.
If you know how a linked list works, then there is no point in writing one for yourself. Most of the STL is infrastructure of a very common nature.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Fabio |
last post by:
Hi everyone,
Is there anybody who can suggest me a link where I can find information
about 'Persistent linked list' ?
I need to implement a linked list where every node is a structure like the...
|
by: C++fan |
last post by:
Suppose that I define the following class:
class example_class{
public:
example_class();
void funtion_1();
void function_2();
protected:
|
by: Maurice |
last post by:
how could you pass the head from a linked list class so that it could be
used in a main file?
here is the content of the linkedlist.h file:
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
...
|
by: drewy2k12 |
last post by:
Heres the story, I have to create a doubly linked list for
class, and i have no clue on how to do it, i can barely create a
single linked list. It has to have both a head and a tail pointer,
and...
|
by: Susan.Adkins |
last post by:
Alright, I must say that the problem my teacher has given us to do has
royally annoyed me.
We are to take a letter *txt file* and then read in the words.
Make 2 seperate lists *even and odd* for...
|
by: theeverdead |
last post by:
Ok I have a file in it is a record of a persons first and last name. Format is like:
Trevor Johnson
Kevin Smith
Allan Harris
I need to read that file into program and then turn it into a linked...
|
by: QiongZ |
last post by:
Hi, I just recently started studying C++ and basically copied an example in the textbook into VS2008, but it doesn't compile. I tried to modify the code by eliminating all the templates then it...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |