Question
help! need help c++ Class Attributes: Node - Node is a nested struct that defines the Node. value - stores the integer value to be
help! need help c++
Class Attributes:
Node - Node is a nested struct that defines the Node.
value - stores the integer value to be stored in the list.
next - stores the memory address of the next node in the list.
head - a Node pointer that holds the memory address of the head node.
constructor - initializes head to nullptr.
destructor - frees all memory created by the MyVector object.
push_back - accepts an integer as it's only argument and appends it to the linked list.
pop_back - removes the last node in the linked list.
at - returns the value of the i'th node in the list by reference. Throws a C-string exception "OUT OF BOUNDS", if it's argument is invalid.
clear - frees all memory used by the list, setting head back to nullptr.
size - returns the number of nodes in the list.
None of the above methods interacts with the user in any way.
Demonstrate your class in a program that does the following:
Uses push_back method to add ten random numbers to a MyVector object.
Uses the size method to display the number values in the object.
Calls the at method ten times to display the contents of the object.
Uses the at method to change the 3rd value in the object to 99.
Uses the pop_back method to remove the last value in the object.
Calls the at method nine times to display the changed contents of the object.
My Vector Node value: int next Node" -head: Node* +MyVector): +-MyVector): +push back(i: int): void *pop_back(); void tat(ic int); ints +clear(): void *size(): int Class Attributes: Node - Node is a nested struct that defines the Node. value - stores the integer value to be stored in the list. a next - stores the memory address of the next role in the list head - a Node pointer that holds the memory address of the head node. - constructor - initializes head to null ptr. destructor - frees all memory created by the MyVector object. push_back - accepts an integer as it's only argument and appends it to the linked list. . pop_back- removes the last node in the linked list at-returns the value of the i'th node in the list by reference. Throws a C-string exception "OUT OF BOUNDS', if it's argument is invalid. clear - frees all memory used by the list, setting head back to nullptr. + size - returns the number of nodes in the list. None of the above methods interacts with the user in any way. Demonstrate your class in a program that does the following: Uses push_back method to add ten random numbers to a MyVector object. Uses the size method to display the number values in the object. Calls the at method ten times to display the contents of the object. Uses the at method to change the 3rd value in the object to 99. Uses the pop_back method to remove the last value in the object. Calls the at method nine times to display the changed contents of the objectStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started