i do i get started on cpp file
I need a quick explanation of how to write the cpp file for my program. I have the class written below. I don't know how to use
the code tags that you guys like. Sorry. Can someone help me get started on the cpp file, please?. Give me an example in you can please.
I have to write a class called date. I also have to write a cpp file for the class that represents a calendar date in terms of month,
day and year, as on a 12 month calander. The valid months are Jan. through December, a valid day must correspond to a valid
day for the given month and the year must be positive number. The object should store a format setting to be used
for display of dates to the screen. There is more than one possible format. The class features should work exactly as specified,regardless of what program might be using Date objects. Dates should be specified with integers. Month values with be 1 for Jan,
2 for Feb and so on. Valid day will be an integer between 1 and the number of days in the month. Valid year values are positive
numbers.
#ifndef date_H
#define date_H
class date
{
public:
date(); //default constructor
date(int m , int d, int y);
void input();// promts user to enter date
void show();//outputs date
bool Set (int m, int d, int y); //sets date to specified values
bool SetFormat (char f);//allows user to change format setting
void Increment();//move date foward one calendar year
private:
int GetMonth();//returns month
int GetDay();// returns day
int GetYear(); //returns year
};//ends class date
#endif
here's what i have thus far
I got two errors that are as a result of the bool statements. Howdo I get them to go away? How would I set up the SetFormat function? Would I leave the Show function blank?
Code:
#include <iostream>
#include "date.h"
using std::cout;
int Month;
int Day;
int Year;
date::date()
{
Month=1;
Day=1;
Year=1990;
}
void date::Increment()
{
Year++;
}
void date::input()
{
cout<< "Enter the date:";
}
void date::show()
{
}
date::bool Set(int m, int d, int y)
{
return true;
}
date::bool SetFormat(char f)
{
SetFormat ('L')
return true;
}