Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ : Create the program that converts month in number to string month Implement the ostream function The example output: Enter the date (MM-DD): 02-01

C++ :

Create the program that converts month in number to string month

Implement the ostream function

The example output:

Enter the date (MM-DD): 02-01

02-01 = Feb. 1

-------------------------Date.h--------------------

#ifndef DATE_H

#define DATE_H

#include

#include

using namespace std;

class Date {

private:

unsigned month_, day_;

static const string MONTHS[12];

public:

//constructors

Date();

//Overloaded operators

friend ostream& operator<<(ostream&, const Date&);

friend istream& operator>>(istream&, Date&);

};

#endif

----------------------date.cpp-------------

#include

#include "Date.h"

using namespace std;

const string Date::MONTHS[12] = {"Jan.", "Feb.", "Mar.", "Apr.", "May.", "Jun.", "Jul.", "Aug.", "Sept.", "Oct.", "Nov.", "Dec."};

Date::Date() : month_(1), day_(1) {

}

istream& operator>>(istream& input, Date& a)

{

unsigned month_, day_;

input >> month_;

input.ignore();

input >> day_;

return input;

}

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

Step: 3

blur-text-image

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

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions

Question

Bring out the limitations of planning.

Answered: 1 week ago

Question

Why should a business be socially responsible?

Answered: 1 week ago

Question

Discuss the general principles of management given by Henri Fayol

Answered: 1 week ago

Question

Detailed note on the contributions of F.W.Taylor

Answered: 1 week ago

Question

8. Do the organizations fringe benefits reflect diversity?

Answered: 1 week ago