forked from ucsb-cs24-w22/lab03_starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintlist.h
More file actions
42 lines (31 loc) · 1.24 KB
/
intlist.h
File metadata and controls
42 lines (31 loc) · 1.24 KB
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
// intlist.h
// Linked list header file
#ifndef INTLIST_H
#define INTLIST_H
class IntList {
public:
// constructor and 3 methods already done in intlist.cpp (NO CHANGE):
IntList(); // constructor
void append(int value); // append value at end of list
void print() const; // print values separate by ' '
int count() const; // return count of values
// destructor, copy constructor and 6 other METHODS YOU MUST
// IMPLEMENT IN intlist.cpp (NO CHANGE HERE):
~IntList(); // destructor
IntList(const IntList& source); //copy constructor (deep copy)
int sum() const; // sum of all values
bool contains(int value) const; // true if value in list
int max() const; // maximum value
double average() const; // average of all values
void insertFirst(int value); // insert new first value
IntList& operator=(const IntList& source); //overloaded (NO CHANGE)
private:
// (Optional) You can add some private helper functions here.
// definition of Node structure (DO NOT CHANGE):
struct Node {
int info;
Node *next;
};
Node *first; // pointer to first node (DO NOT CHANGE):
};
#endif