C++ Scoped Enums Question

Introduction

Write a program that defines a scoped enum representing days of the week.

Create an object of that enum, assign it a value, check if the value is Monday, if it is, change the object value to another enum value:

You can use the following code structure.

#include <iostream> 

int main() 
{ 
    //your code here
} 


#include <iostream> 

enum class Days 
{ 
    Monday, 
    Tuesday, 
    Wednesday, 
    Thursday, 
    Friday, 
    Saturday, 
    Sunday 
}; 

int main() 
{ 
    Days myday = Days::Monday; 
    std::cout << "The enum value is now Monday." << '\n'; 

    if (myday == Days::Monday) 
    { 
        myday = Days::Friday; 
    } 
    std::cout << "Nobody likes Mondays. The value is now Friday."; 
} 



PreviousNext

Related