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
{
return (numElements == maxsize);
}
template
bool SimpleVector
{
return (numElements == 0);
}
template
SimpleVector
{
//let's set a default size for this vector
maxsize = 50;
//allocate the array list
list = new T[maxsize];
numElements = 0;
}
template
SimpleVector
{
//let's set a default size for this vector
maxsize = nelems;
//allocate the array list
list = new T[maxsize];
numElements = 0;
}
template
SimpleVector
{
//release memory
delete[]list;
}
template
void SimpleVector
{
if (!isFull())
{
//add this object T to the list at next empty postion
list[numElements] = newItem;
//increment counter
numElements++;
}
}
template
T& SimpleVector
{
//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
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