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?

I can't figure out this error message. I tried adding the semicolon

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 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!