Computers and Technology

You are required to come up with a single header file (IntList. h) that declares and implements the IntNode class (just copy it exactly as it is below) as well as declares the IntList Class interface only. You are also required to come up with a separate implementation file (IntList. cpp) that implements the member functions of the IntList class. While developing your IntList class you must write your own test harness (within a file named main. cpp).

Never implement more than 1 or 2 member functions without fulling testing them with your own test harness. IntNode struct I am providing the IntNode class you are required to use. Place this class definition within the IntList. h file exactly as is. Make sure you place it above the definition of your IntList class. Notice that you will not code an implementation file for the IntNode class. The IntNode constructor has been defined inline (within the class declaration). Do not write any other functions for the IntNode class. Use as is.

struct IntNode {

int data;

IntNode *next;

IntNode(int data) : data(data), next(0) {} };

IntList class Encapsulated (Private) Data Fields

head: IntNode *

tail: IntNode *

Public Interface (Public Member Functions)

IntList(): Initializes an empty list.

~IntList(): Deallocates all remaining dynamically allocated memory (all remaining IntNodes). void display() const: Displays to a single line all of the int values stored in the list, each separated by a space. This function does NOT output a newline or space at the end.

void push_front(int value): Inserts a data value (within a new node) at the front end of the list.

void pop_front(): Removes the value (actually removes the node that contains the value) at the front end of the list. Does nothing if the list is already empty.

bool empty() const: Returns true if the list does not store any data values (does not have any nodes), otherwise returns false. main. cpp test harness for lab

Use this main. cpp file for testing your IntList:

. #include using namespace std; #include "IntList. h" int main() {

//tests constructor, destructor, push_front, pop_front, display { cout << "\nlist1 constructor called"; IntList list1;cout << "\npushfront 10"; list1.push_front(10); cout << "\npushfront 20"; list1.push_front(20); cout << "\npushfront 30"; list1.push_front(30); cout << "\nlist1: "; list1.display(); cout << "\npop"; list1.pop_front(); cout << "\nlist1: "; list1.display(); cout << "\npop"; list1.pop_front(); cout << "\nlist1: "; list1.display(); cout << "\npop"; list1.pop_front(); cout << "\nlist1: "; list1.display(); cout << endl; } cout << "list1 destructor called" << endl; return 0;}

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 21:00, tiffg2588
Will this setup result in what kathy wants to print?
Answers: 2
image
Computers and Technology, 24.06.2019 01:00, Timeisjesus
Answer these and get 40 points and brainliest
Answers: 1
image
Computers and Technology, 24.06.2019 14:30, thelordoftheknowwjo4
In a home that has 120 v service, there is an electric appliance that has a resistance of 12 ohms. how much power will this appliance consume? a. 10 w b. 120 w c 1200 w d. 1440 w
Answers: 1
image
Computers and Technology, 25.06.2019 01:00, lilybear1700
What phrase indicates someone has knowledge and understanding of computer, internet, mobile devices and related technologies?
Answers: 1
Do you know the correct answer?
You are required to come up with a single header file (IntList. h) that declares and implements the...

Questions in other subjects:

Konu
Geography, 24.10.2020 21:20
Konu
History, 24.10.2020 21:20
Konu
Chemistry, 24.10.2020 21:20