Instructions for answering I have help for Q2, Q3, and Q4, I have codes you will

Instructions for answering
I have help for Q2, Q3, and Q4, I have codes you will modify and use to answer Q2, Q3, and Q4. For these questions, you need to modify the codes according to the question given and use the part that is suitable for the question. Please answer all questions (Q1, Q2, Q3, Q4).
When you answer them I need them like this :
Q1- type your answer
Q2- type your answer
Q3- type your answer
Q4- type your answer
————————————————————————————————
Here questions :
Q1- Write a main function to test the function max. Your program should ask the user to enter two numbers (an int and a double), then it displays the maximum.
Example of the output of the program:
The maximum of 6 and 8.3 is: 8.3
Q2- Create a new CPP file named classTemplates.cpp
Implement the class template named SimpleVector which may include general data types. The SimplteVector might be a list of ints, a list of doubles, etc.
Q3- Implement the class Time that contains the following properties: int hou, int min, int sec.
Implement the getters of the class Time.
Q4- Test your code by creating an instance of SimpleVector holding elements of type Time, the size of the array is 10, fill in the table and display it
————————————————————————————————
Here the codes
#include
#include
#include
using namespace std;
template
class SimpleVector
{
private:
T *aptr;
int arraySize;
void memError();
void subError();
public:
SimpleVector()
{
aptr = 0;
arraySize = 0;
}
SimpleVector(int);
SimpleVector(const SimpleVector &);
~SimpleVector();
int size() const
{ return arraySize; }
T &operator[](const int &);
T getElementAt(int sub);
};
template
SimpleVector::SimpleVector(int s)
{
arraySize = s;
try
{
aptr = new T[s];
}
catch(bad_alloc)
{
memError();
}
}
template
SimpleVector::SimpleVector(const SimpleVector &obj)
{
arraySize = obj.arraySize;
aptr = new T[arraySize];
if (aptr == 0)
memError();
for (int count =0; count < arraySize; count++) *(aptr + count) = *(obj.aptr + count); } template
SimpleVector::~SimpleVector()
{
if (arraySize > 0)
delete[] aptr;
}
template
void SimpleVector::memError()
{
cout << "ERROR: Cannot allocate memory.n"; exit(EXIT_FAILURE); } template
void SimpleVector::subError()
{
cout << "ERROR: Subscript out of range.n"; exit(EXIT_FAILURE); } template
T &SimpleVector::operator[](const int &sub)
{
if (sub < 0|| sub >= arraySize)
subError();
return aptr[sub];
}
class Date
{
private:
int day;
int month;
int year;
public:
Date()
{
day = 1;
month = 1;
year = 1900;
}
Date(int d, int m, int y)
{
day = d;
month = m;
year = y;
}
int getDay()
{ return day; }
int getMonth()
{ return month; }
int getYear()
{ return year; }
Date &operator=(const Date &obj)
{
day = obj.day;
month = obj.month;
year = obj.year;
return *(this);
}
int operator==(const Date &obj)
{
if((day == obj.day) && (month == obj.month) && (year == obj.year))
return 1;
else
return 0;
}
};
template
T SimpleVector::getElementAt(int sub)
{
if (sub < 0 || sub >= arraySize)
subError();
return aptr[sub];
}
template
class SearchableVector : public SimpleVector
{
public:
SearchableVector() : SearchableVector()
{
}
SearchableVector(int size) : SimpleVector(size)
{
}
int findItem(const T);
};
template
int SearchableVector::findItem(const T item)
{
for (int count = 0; count <= this->size(); count++)
{
if (this->getElementAt(count) == item)
return count;
}
return -1;
}
int main()
{
const int SIZE = 10;
int count;
SearchableVector DateTable(SIZE);
for (count = 0; count < SIZE; count++) { DateTable[count] = Date(count, 05, 2023); } cout << "These values are in date table:n"; for (count = 0; count

Posted in C++

Place this order or similar order and get an amazing discount. USE Discount code “GET20” for 20% discount