#Creating simple Date Class

8 messages · Page 1 of 1 (latest)

solemn waveBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

worthy rose
#

#ifndef DATE_H
#define DATE_H

class Date
{
private:
int m_year;
int m_month;
int m_day;

public:
Date();
Date(int year, int month, int day);

void setDate(int year, int month, int day);
void printDate(int year, int month, int day);

int getYear() { return m_year; }
int getMonth() { return m_month; }
int getDay() { return m_day; }

};
#endif

#

the above is my date.h file thus far

#

#include <iostream>

#include "date.h"

Date::Date()
{
m_year = 1900;
m_month = 1;
m_day = 1;
}

Date::Date(int year, int month, int day)
{
m_year = year;
m_month = month;
m_day = day;
}

void Date::setDate(int year, int month, int day)
{
std::cin >> year;
std::cin >> month;
std::cin >> day;
}

void Date::printDate(int year, int month, int day)
{
std::cout << year << "/" << month << "/" << day << "\n";
}

#

my date.cpp file

#

i'm starting with the date class then moving on to the rest, it's due in less than 4 hours

solemn waveBOT
#

@worthy rose

Please Do Not Delete Posts!

Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.

worthy rose
#

!solved