Homework Help Please!

I need help with this assignment for school, and I am stuck on what the problem is...Any help or guidance is appreciated!

My instructions for school:
(Circular linked lists) This chapter defined and identified various operations on a circular linked list.

Write the definitions of the class circularLinkedList and its member functions. (You may assume that the elements of the circular linked list are in ascending order.)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//In my main.cpp file
//This program tests various operation of a linked list
//45 67 23 89 -999

#include <iostream> 
#include "circularLinkedList.h"
 
using namespace std; 

int testCopyConstructor(H_circularLinkedList uint);

int main()

{

int input=0;

int A;

LinkedList One;

while (1)

{

if (input==0)

{

cout<<"1. Add\n2. Delete\n3. Display\n";

cout<<"Enter your choice\n";

cin>>input;

}

else if (input==1)

{

cout<<"Enter the data\n";

cin>>A;

One.add(A);

cout<<"Press 0 to go back to main menu\n";

cin>>input;

}

else if (input==2)

{

if (One.empty())

cout<<"The list is empty\n";

else

{

cout<<"Enter the data to be deleted\n";

cin>>A;

One.Delete(A);

}

cout<<"Press 0 to go back to main menu\n";

cin>>input;

}

else if (input==3)

{

if (One.empty())

cout<<"The list is empty\n";

else

One.isplay();

cout<<"Press 0 to go back to main menu\n";

cin>>input;

}

}

}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
//In my circularLinkedList.cpp file
#ifndef H_circularLinkedList
#define H_circularLinkedList
  
#include <iostream>
#include <cassert> 
using namespace std;

struct node

{

int data;

node * next;

};

class LinkedList

{

public:

LinkedList();

void add(int A);

bool empty(); // return true if the list is empty, otherwise return false void InsertInOrder(ElementType x);//insert a value x in numerical order in the list

void Delete(int x); //if value x is in the list, remove x

void Display();// Display the data values in the list
    
void isplay();

private:

node * first;//pointer to the first node in the list

};

LinkedList::LinkedList()

{

first=NULL;

}

void LinkedList::add(int A)

{

if (first==NULL)

{

first=new node;

first->data=A;

first->next=first;

}

else if (first->next==first)

{

node *curr=first->next;

curr=new node;

curr->data=A;

curr->next=first;

first->next=curr;

}

else

{

node *curr=first->next;

node *prev=NULL;

while (curr!=first)

{

prev=curr;

curr=curr->next;

}

curr=new node;

curr->data=A;

curr->next=first;

prev->next=curr;

}

}

bool LinkedList::empty()

{

if (first==NULL)

return true;

else return false;

}

void LinkedList::Delete(int A)

{

node *curr=first->next;

node *prev=NULL;

bool flag=true;

if (first->data==A)

{

first=first->next;

delete first;

flag=false;

}

else

{

while (flag && curr!=first)

{

if (curr->data==A)

{

prev->next=curr->next;

delete curr;

flag=false;

}

prev=curr;

curr=curr->next;

}

if (flag==true)

cout<<"Data not foundn";

}

}

void LinkedList::isplay()

{

cout<<first->data<<endl;

node *curr=first->next;

while (curr!=first)

{

cout<<curr->data<<endl;

curr=curr->next;

}

}

#endif 
I am stuck on what the problem is

So are we, as you've given us no information at all about what problem you have.
My problem is my code will not compile, and my program won't run and I don't know why.
My problem is my code will not compile

Then your compiler will be giving you helpful compiler messages, stating what line is failing to compile, and what the specific problem is on that line. Use that information to help fix the problem.

If there are specific errors you don't understand, or can't fix, then you can always ask us specific questions about those errors, provided you give us the information you have about them.

my program won't run

That one's easy. It won't run, because it doesn't exist. If the code doesn't compile, then you simply don't have an application to run. You're welcome.
Last edited on
Topic archived. No new replies allowed.