Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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?

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Management Systems

Authors: Patricia Ward, George A Dafoulas

1st Edition

ISBN: 1844804526, 978-1844804528

More Books

Students also viewed these Databases questions

Question

3. Have we aligned IT with our business strategy and goals?

Answered: 1 week ago

Question

=+ What are the information and consultation requirements?

Answered: 1 week ago

Question

=+ Should the MNE belong (why, why not)?

Answered: 1 week ago