i dont know how this stuff is supposed to work... my error comes up in the member function definitions for date class page. This is the error --> c:\c++\exercise7_07\chapter7.cpp(14) : error C2660: 'setdate' : function does not take 2 parameters.
the point of the program is to output a date in multiple formats(ddd yyyy, mm/dd/yy, June 14, 1992). Use overloaded constructors to create Date objects initialized with dates of the formats in part (a) and create a date constructor hat reads the system date using the standerd library function time.h and sets the date members.(havent started the last part yet) please help ASAP!!!
this is what i have so far -->
//header file
//Declaration of the Date class
//Member functions defined in chapter7.cpp
//preprocessor directives that prevent multiple inclusions of
//header files
#ifndef EXERCISE7_07_h
#define EXERCISE7_07_h
class date {
public:
date(int, int, int); //constructors
date(int, int);
date(char, int, int);
date();
//set functions
void setdate(int, int, int); //sets month, day, year
void setmonth(int); //sets month
void setday(int); //sets day
void setyear(int); //sets year
//get functions
int getmonth(); //return month
int getday(); //return day
int getyear(); //return year
void printwords(); //output in form of June 14, 1992
void printnumbers(); //output in form of MM/DD/YY
void printjulian(); //output in form of DDD YYYY
private:
int month; // 01-12
int day; // 1-31
int year; // year
};
#endif
//.cpp file #1
//member function definitions for Time class
#include<iostream>
#include"exercise7_07.h"
using std::cout;
date::date( int month, int day, int year)
{ setdate (month, day, year); }
date::date( int day, int year)
{ setdate (day, year); }
date::date( char month, int day, int year)
{ setdate (month, day, year); }
//set the values of month, day, year
void date::setdate( int dd, int mm, int yyyy)
{
setday(dd);
setmonth(mm);
setyear(yyyy);
}
//set day value
void date::setday(int dd)
{ day= (dd>=1 && dd<=31) ? dd : 0;}
//set month value
void date::setmonth(int mm)
{ month= (mm<=01 && mm<=12) ? mm : 0;}
//set year value
void date::setyear(int yy)
{ year= yy;}
//get day value
int date::getday() {return day;}
//get month value
int date::getmonth() {return month;}
//get year value
int date::getyear() {return year;}
//prints date in MM/DD/YY format
void date::printnumbers()
{
cout << month << "/" << day << "/" << year;
}
//prints date in worded format
void date::printwords()
{
char *newmonth[13]{" ", "January","February","March","April","May","June", "July","August","September","October","November"," December"}
if (month==1)
cout << newmonth[1] <<" " <<day <<"," <<year;
if (month==2)
cout << newmonth[2] <<" " <<day <<"," <<year;
if (month==3)
cout << newmonth[3] <<" " <<day <<"," <<year;
if (month==4)
cout << newmonth[4] <<" " <<day <<"," <<year;
if (month==5)
cout << newmonth[5] <<" " <<day <<"," <<year;
if (month==6)
cout << newmonth[6] <<" " <<day <<"," <<year;
if (month==7)
cout << newmonth[7] <<" " <<day <<"," <<year;
if (month==8)
cout << newmonth[8] <<" " <<day <<"," <<year;
if (month==9)
cout << newmonth[9] <<" " <<day <<"," <<year;
if (month==10)
cout << newmonth[10] <<" " <<day <<"," <<year;
if (month==11)
cout << newmonth[11] <<" " <<day <<"," <<year;
if (month==12)
cout << newmonth[12] <<" " <<day <<"," <<year;
}
}
//prints date in Julian format
void date::printjulian()
{
int JulDay;
if (month==1)
JulDay =day;
if (month==2)
JulDay = day + 31;
if (month==3)
JulDay = day + 31 + 28;
if (month==4)
JulDay = day + 31 + 28 + 31;
if (month==5)
JulDay = day + 31 + 28 + 31 + 30;
if (month==6)
JulDay = day + 31 + 28 + 31 + 30 + 31;
if (month==7)
JulDay = day + 31 + 28 + 31 + 30 + 31 + 30;
if (month==8)
JulDay = day + 31 + 28 + 31 + 30 + 31 + 30 + 31;
if (month==9)
JulDay = day + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31;
if (month==10)
JulDay = day + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30;
if (month==11)
JulDay = day + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31;
if (month==12)
JulDay = day + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30;
cout << JulDay << " " << year << "\n";
}
//.cpp file #2
#include <iostream>
#include "exercise7_07.h"
int main(void)
{
date d;
d.setday(31);
d.setmonth(3);
d.setyear(1994);
d.getday();
d.getmonth();
d.getyear();
d.printjulian();
d.printnumbers();
d.printwords();
return 0;
}
the error is happening is the first .cpp file, int the lines
date::date( int day, int year)
{ setdate (day, year); }
I know that setdate needs 3 parameters, but i dont see where the third one is supposed to some from!!