Constructors-1

Create Calendar class with day, month and year as data members. Include default and parameterized constructors to initialize a Calendar object with a valid date value. Define a function AddDays to add days to the Calendar object. Define a display function to show data in “dd/mm/yyyy” format.




class calendar
{
    int day;
    int month;
    int year;
    public:
    calendar()
    {
        day=month=year=0;
    }
    calendar(int d, int m,int y)
    {
        day=d;
        month=m;
        year=y;
    }
    void adddays()
    {
        int dd;
        cout<<"\n Enter days to add";
        cin>> dd;
        day=day+dd;
        if(day>=31)
        {

            month++;
            day=day-31;

        }
        if(month>=12)
        {
            year++;
            month-=12;
        }
        cout<<day<<":"<<month<<":"<<year;

    }
};
void main()
{

    calendar c1(12,6,12);
    c1.adddays();

}