Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I don\'t understand the syntax for implementing this method (see description). D

ID: 3751744 • Letter: I

Question

I don't understand the syntax for implementing this method (see description).

Description:

Add a static method named fiveHolidays() that returns a vector of five Date
pointers ( std::vector<Date*> ) representing five holidays of your choosing.

static int fiveHolidays() {

std::vector<Date*> holidays(5);

int holidayList[] = {(1, 2, 3), (4, 5, 6), (7, 8, 9), (10, 11, 12), (13, 14, 15)}; // These are random dates, I cange change them to holidays later.

return holidays;

}

Example Test Case that I will have to pass:

Date::fiveHolidays().size() == 5

Explanation / Answer

I am assuming the Date class by myself as you have not specified it Question seems to have another error and that is of return type which is specified as int but in the end you are trying to return vector of Date

Your question requirement is not clearly specified but I have tried to give you what you wanted that is converting the 2-d array to vector of Date has been done by me If you are looking for anything else than leave a comment with proper specification of your requirement

Below is the C++ code I hope that i have provided sufficient comments for your better understanding Note that I have done proper indentation but this code is automatically left alligned on this interface

#include<bits/stdc++.h>
using namespace std;

class Date
{
private:
int day,month,year;
public:
void setDate(int d,int m,int y)
{
day=d;month=m;year=y;
}
static int fiveHolidays()
{
vector <Date*>holidays(5);
int holidayList[5][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}}; // These are random dates
for(int i=0;i<5;i++)
{
holidays[i]->setDate(holidayList[i][0],holidayList[i][1],holidayList[i][2]); //set the date from the array to vector of Date
}
//return holidays;
}
};

Hope i have answered your question satisfactorily.Leave doubts in comment section if any.

Dr Jack
Hire Me For All Your Tutoring Needs
Quick quotes • Clear explanations • Study support
Chat Now And Get Quote