subject

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;}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 21:30
The salespeople at hyperactive media sales all use laptop computers so they can take data with them on the road. you are a salesperson for superduper lightspeed computers talking to hyperactive media sales about upgrading the laptops to windows 10. explain how network location awareness in windows 10 would make the laptops more secure.
Answers: 3
question
Computers and Technology, 23.06.2019 00:00
Suppose you have 9 coins and one of them is heavier than others. other 8 coins weight equally. you are also given a balance. develop and algorithm to determine the heavy coin using only two measurements with the of the balance. clearly write your algorithm in the form of a pseudocode using the similar notation that we have used in the class to represent sorting algorithms
Answers: 1
question
Computers and Technology, 23.06.2019 02:00
Consider the following function main: int main() { int alpha[20]; int beta[20]; int matrix[10][4]; . . } a. write the definition of the function inputarray that prompts the user to input 20 numbers and stores the numbers into alpha. b. write the definition of the function doublearray that initializes the elements of beta to two times the corresponding elements in alpha. make sure that you prevent the function from modifying the elements of alpha. c. write the definition of the function copyalphabeta that stores alpha into the first five rows of matrix and beta into the last five rows of matrix. make sure that you prevent the function from modifying the elements of alpha and beta. d. write the definition of the function printarray that prints any onedimensional array of type int. print 15 elements per line. e. write a c11 program that tests the function main and the functions discussed in parts a through d. (add additional functions, such as printing a two-dimensional array, as needed.)
Answers: 3
question
Computers and Technology, 24.06.2019 09:50
Self contained sequences of actions to be performed are? a. expressions b. algorithms c. functions d. formulas
Answers: 1
You know the right answer?
You are required to come up with a single header file (IntList. h) that declares and implements the...
Questions
question
Mathematics, 16.11.2020 17:20
Questions on the website: 13722361