Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a template class named VectorController. This class has 1 data member a vector; The class should contain 3 constructors : a default constructor, a

Create a template class named VectorController. This class has 1 data member a vector; The class should contain 3 constructors: a default constructor, a constructor that accepts the size of the vector, and a constructor that accepts the size and default value for the vector. The class should also contain the following functions:

Function Definition
setVector sets the value of the vector data member
getVector returns the vector data memeber
setIndexValue sets the value of a specific index in the vector to the value provided by the user or pushes the value to end of the vector if the index does not exist.
getSize returns the size of the vector
minimumValue returns the smallest value in the vector
maximumValue returns the largest value in the vector

Also overload the insertion stream operator (<<). This function should be templated so that you may use the same function with cout and fstream. The output should be as below.

You are provided a driver file to test your code. Do not change its contents.

Hints: (1) All methods are written inside the H file. Refer to the chapter for examples. (2) Use the resize function in the overloaded constructors. (3) The overloaded operator function implementation must be written inside the class definition. Other functions should be written just outside of the declaration in the H file.

Hello I was given the driver.cpp file:

#include #include #include #include #include #include "VectorController.h"

using namespace std;

int main() { VectorController list1; VectorController list2(10); VectorController list3(8, 2); cout << "List 1 Size: " << list1.getSize() << endl; cout << "List 2 Size: " << list2.getSize() << endl; cout << "List 3 Size: " << list3.getSize()<< endl; cout << endl << endl << "Printing List Values" << endl << endl; cout << "List 1" << endl << list1 << endl; cout << "List 2" << endl << list2 << endl; cout << "List 3" << endl << list3 << endl; cout << "Update List 2" << endl; vector test = {"my","first", "name", "is", "not", "written"}; list2.setVector(test); cout << "List 2 Size: " << list2.getSize() << endl; cout << "List 2" << endl << list2 << endl; list3.setIndexValue(7, 60002); cout << "Update List 3" << endl; cout << "List 3" << endl << list3 << endl; cout << fixed << setprecision(3); cout << "List " << setw(10) << left << "Min" <

Now I need VectorController.h file and I need it in C++ thank you!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago