Question
I can't figure out this error message. I tried adding the semicolon after else but that didn't change anything, unless I completely missed the point?
I can't figure out this error message. I tried adding the semicolon after "else" but that didn't change anything, unless I completely missed the point?
Here is my code
#include
#include
using namespace std;
namespace days_months
{
string monthList[12] = {"January","February",
"March","April","May","June","July","August","September","October","November","December"
};
int daysInMonths[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
}
class date{
private:
int days, months, year;
public:
date(){
days = 1;
months = 1;
year = 2001;
}
date(int days, int months, int year){
if ((months>=1 &&months
this->days=days;
this->months=months;
this->year=year;
}
else{this->days=1,
this->month=1,
this->year=2001;}
};
string format_1(){
return string("months")+"/"
+ string("days")+"/"
+string("year").substr(2);
}
string format_2(){
return days_months::monthList[12-1]
+" "+string("days")
+", "+string("year");
}
string format_3(){
return string("days")
+" "+days_months::monthList[12-1]
+" "+string("year");
}
int main(void){
unsigned int days, months, year;
cout
cout
cin>>days;
cout
cin>>months;
cout
cin>>year;
date d(days,months,year);
cout
cout
cout
cout
cout
cout
cout
}
> clang++-7 -pthread -std=c++17 -o main main.cpp Q X main.cpp:30:1: error: expected member name or ';' after declaration specifiers else {this->days=1, A 1 error generated. compiler exit status 1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started