Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions

Question

=+j on to staff their operations in the global marketplace.

Answered: 1 week ago