Question: create the SimpleVector class template. template //T is my datatype classSimpleVector { protected: int maxsize; //number of elements allocated int numElements; //current number of elements

create the SimpleVector class template.

template

//T is my datatype

classSimpleVector

{

protected:

int maxsize; //number of elements allocated

int numElements; //current number of elements

//need a pointer to represent the array

T* list;

public:

SimpleVector();

SimpleVector(int);

~SimpleVector(); //destructor

void insert(T);

T& getItemAt(int);

int size() { return numElements; }

bool isFull();

bool isEmpty();

};

//all function definitions for a template MUST BE IN

//header file. NO .cpp file!

template

bool SimpleVector::isFull()

{

return (numElements == maxsize);

}

template

bool SimpleVector::isEmpty()

{

return (numElements == 0);

}

template

SimpleVector::SimpleVector()

{

//let's set a default size for this vector

maxsize = 50;

//allocate the array list

list = new T[maxsize];

numElements = 0;

}

template

SimpleVector::SimpleVector(int nelems)

{

//let's set a default size for this vector

maxsize = nelems;

//allocate the array list

list = new T[maxsize];

numElements = 0;

}

template

SimpleVector::~SimpleVector()

{

//release memory

delete[]list;

}

template

void SimpleVector::insert(T newItem)

{

if (!isFull())

{

//add this object T to the list at next empty postion

list[numElements] = newItem;

//increment counter

numElements++;

}

}

template

T& SimpleVector::getItemAt(int pos)

{

//make sure pos is valid

if (pos >= 0 && pos < numElements)

{

return list[pos];

}

}

Then use the SimpleVector class template to manage a list of Employees.

Create an Employee class. Make sure you can calculate employee pay (make sure to handle overtime properly).

Set up this menu:

1 - add employee (prompt for name, hours worked, rate)

2 - print payroll (print report with each employee's name and gross pay)

3 - quit

Show output with at least 3 employees entered.

please create a different emplyee class and a different main

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!