L
L
Leo_SAN2020-09-23 23:35:28
OOP
Leo_SAN, 2020-09-23 23:35:28

Output an array through a class?

I have an array of holidays in the file Holidays.h

#pragma once
#include "Month.h"
struct Holiday {
  const char name[25];
  Month month;
  int day;
};
Holiday holidays[] = {
  {"New Year",Month::JAN,1},{"Orthodox Christmas",Month::JAN,7},{"Women's Day",Month::MAR,8},
  {"Labor Day",Month::MAY,1},{"Victory Day",Month::MAY,9},{"Independence Day",Month::JUL,3},
  {"October Revolution Day",Month::NOV,7},{"Catholic Christmas",Month::DEC,25},{"Orthodoxy Easter",Month::DEC,25},
  {"Catholic Easter",Month::DEC, 25},{"Radonitsa",Month::DEC,25}
};
int amountOfHolidays = sizeof(holidays) / sizeof(*holidays);


and Month.h file:
#include <string>
enum class Month{ JAN = 1, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC};
const int MONTHCOUNT = static_cast<int>(Month::DEC) - static_cast<int>(Month::JAN) + 1;
const std::string monthString[MONTHCOUNT] = {"january", "february", "march", "april", "may", "june", 
                    "july", "august", "september", "november", "december" };


How can I display all holidays using a class?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
HemulGM, 2020-09-24
@HemulGM

Just like without a class. Write a method in a class. In methods, output an array. Call the class method.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question