Here is the program I'm trying to run. These errors appear:
37:28 no matching function for call to...
52:67 error default argument given for parameter 1/2/3
I'm not sure how to fix them.
Also, on my header dataType.h
I am getting these notes:
29:7 candidate expects 0 arguments, 1 provided
32:5 previous specification in ...
Are these notes something to worry about? If so, how can I fix them?
dataTypeImp.cpp
#ifndef dateType_H
#define dateType_H
#include <iostream>
#include "dateType.h"
using namespace std;
void dateType::setDate(int month, int day, int year) {
dMonth = month;
dDay = day;
dYear = year;
};
//Function to set the date.
//The member variables dMonth, dDay, and dYear are set
//according to the parameters
//Postcondition: dMonth = month; dDay = day;
// dYear = year
int dateType::getDay() const {
return dDay;
}
//Function to return the day.
//Postcondition: The value of dDay is returned.
int dateType::getMonth() const {
return dMonth;
}
//Function to return the month.
//Postcondition: The value of dMonth is returned.
int dateType::getYear() const {
return dYear;
}
//Function to return the year.
//Postcondition: The value of dYear is returned.
void dateType::printDate() const {
cout << "Date: " << dMonth << "-" << dDay << "-" << dYear;
if (isLeapYear(true)) {//**<<THIS IS ERROR 37:28**
cout << "This is a leap year";
}
else {
cout << "This is not a leap year";
}
}
//Function to output the date in the form mm-dd-yyyy.
bool isLeapYear(int dYear) {
bool isLeapYear = (dYear%4);
return isLeapYear;
}
//Function to determine whether the year is a leap year.
dateType::dateType(int month = 1, int day = 1, int year = 1900) {
setDate(month, day, year);//**^^THIS IS ERROR 52:67^^**
}
//Constructor to set the date
//The member variables dMonth, dDay, and dYear are set
//according to the parameters
//Postcondition: dMonth = month; dDay = day;
// dYear = year
//If no values are specified, the default values are
//used to initialize the member variables.
#endif
dataType.h
#ifndef date_H
#define date_H
class dateType
{
public:
void setDate(int month, int day, int year);
//Function to set the date.
//The member variables dMonth, dDay, and dYear are set
//according to the parameters
//Postcondition: dMonth = month; dDay = day;
// dYear = year
int getDay() const;
//Function to return the day.
//Postcondition: The value of dDay is returned.
int getMonth() const;
//Function to return the month.
//Postcondition: The value of dMonth is returned.
int getYear() const;
//Function to return the year.
//Postcondition: The value of dYear is returned.
void printDate() const;
//Function to output the date in the form mm-dd-yyyy.
bool isLeapYear(); //**<<THIS IS NOTE 29:7**
//Function to determine whether the year is a leap year.
dateType(int month = 1, int day = 1, int year = 1900);//**<<THIS IS NOTE 32:5**
//Constructor to set the date
//The member variables dMonth, dDay, and dYear are set
//according to the parameters
//Postcondition: dMonth = month; dDay = day;
// dYear = year
//If no values are specified, the default values are
//used to initialize the member variables.
private:
int dMonth; //variable to store the month
int dDay; //variable to store the day
int dYear; //variable to store the year
};
#endif
main.cpp
#include <iostream>
#include "dateType.h"
using namespace std;
int main() {
int month;
int day;
int year;
//Verifying inputs then using get function
dateType dDate;
cout << "Please input a date in the format month-day-year"
<< "starting with month" << endl;
cin >> month;
while(month<1 || month>12 || cin.fail()) {
cin.clear();
cout << "Please enter a number between 1 and 12 for the month." << endl;
cin >> month;
}
dDate.getMonth();
//Verifying input then using get function
cout << "Please enter a year" << endl;
cin >> year;
while(year<1 || cin.fail()) {
cin.clear();
cout << "Please enter a positive number for the year." << endl;
cin >> year;
}
dDate.getYear();
/*Using a switch to determine which months have how many days
and to check if there is a leap year to include feb 29
*/
switch(month) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
cout << "Please enter a day of the month" << endl;
cin >> day;
while(day<1 || day>31 || cin.fail()) {
cin.clear();
cout << "Please enter a day of the month between 1 and 31" << endl;
cin >> day;
}
break;
case 4:
case 6:
case 9:
case 11:
cout << "Please enter a day of the month" << endl;
cin >> day;
while (day<1 || day>30 || cin.fail()) {
cin.clear();
cout << "Please enter a day of the month between 1 and 30" << endl;
cin >> day;
}
break;
case 2:
cout << "Please enter a day of the month" << endl;
cin >> day;
if(dDate.isLeapYear()){
while(day<1 || day>29 || cin.fail()) {
cin.clear();
cout << "Please enter a day of the month between 1 and 29" << endl;
cin >> day;
}
}else{
while(day<1 || day>28 || cin.fail()) {
cin.clear();
cout << "Please enter a day of the month between 1 and 28" << endl;
cin >> day;
}
dDate.getDay();
}
break;
}
//end of switch
dDate.setDate(month, day, year);
dDate.printDate();
return 0;
}