ENUMS in every programming language (All you need to know)

preview_player
Показать описание
📚 Learn how to solve problems and build projects with these Free E-Books ⬇️

Experience the power of practical learning, gain career-ready skills, and start building real applications!
This is a step-by-step course designed to take you from beginner to expert in no time!
💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
Use it quickly, because it will be available for a limited time.

I use it to enhance the performance, features, and support for C, C#, and C++ development in Visual Studio.
It is a powerful, secure text editor designed specifically for programmers.

However, please don't feel obligated to do so. I appreciate every one of you, and I will continue to share valuable content with you regardless of whether you choose to support me in this way. Thank you for being part of the Code Beauty community! ❤️😇

In this video, I'll teach you everything you need to know about enumerations in every programming language.
By using enums you increase compile-time checking of your code and avoid errors that can happen by using invalid constants (numbers or strings). This is because enums let you define which values are legal to use.
You'll also learn about the relationship between enums and loops, enums and functions, casting enums and handling user input, as well as iterating through enum elements and using an enum as a function parameter.
After watching the entire video you'll be able to understand what are enums and apply this knowledge to any other programming language. This will help you to write cleaner code that will be easier to understand and maintain.

Contents:
00:00 - What is enum?
02:53 - How to create an enum?
03:54 - Enums under the hood
05:21 - How to change the value of the enum member?
08:07 - Casting int to an enum (Handling user input)
11:13 - Make your first program with enums (+ tips to fix bugs)
14:10 - How to iterate through enum elements?
17:06 - Enum as a function parameter

Other courses mentioned in this video:

Add me on:
Рекомендации по теме
Комментарии
Автор

📚 Learn how to solve problems and build projects with these FREE E-Books ⬇
Experience the power of practical learning, gain career-ready skills, and start building real applications!
This is a step-by-step course designed to take you from beginner to expert in no time!
💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
Use it quickly, because it will be available for a limited time.

Code from this video:

#include <iostream>
using namespace std;

enum EyeColor {

Brown=1,
Blue=22,
Green=3,
Gray=4,
Heterochromia,
Other
};

void getEyeColorDetails(EyeColor myEyeColor) {

switch (myEyeColor) {
case Brown: cout << "70% of the population has brown eyes, making it the most common eye color worldwide. Scientists believe that everyone on Earth had brown eyes around 10, 000 years ago. People with brown eyes are less likely to develop eye cancer, macular degeneration, and diabetic retinopathy than those with lighter colored eyes."; break;
case Blue: cout << "Blue is the second most common eye color globally, with estimates suggesting that 8–10% of people have blue eyes. In the U.S., that proportion is higher, at about 27%. Scientists believe that it is possible to trace all blue-eyed people back to a common ancestor, who likely had a genetic mutation that reduced the amount of melanin in the iris. Most people with blue eyes are of European descent."; break;
case Green: cout << "An estimated 2% of the population has green eyes, making them very rare overall. However, green eyes are very common in some parts of the world, including Ireland and Scotland. In the U.S., about 9% of people have green eyes, and most of them descend from ancestors from Ireland and Scotland."; break;
case Gray: cout << "Close to 3% of the population has gray eyes. People with gray eyes are perceived as mysterious and wise. They often experience Photophobia (sensitivity to light) with a mild to moderate reaction to bright sunlight."; break;
case Heterochromia: cout << "Heterochromia - in which a person has more than one eye color -affects less than 1% of people. The two eyes might be completely different from one another, or one part of the iris might be different than the rest."; break;
case Other: cout << "Your eye color is very rare!"; break;
}
}

int main()
{

/* ierate through enum
for (int myEyeColor = Brown; myEyeColor != Other; myEyeColor++) {}*/

/*cast int to enum
int userNumber = 2;
EyeColor eyeColorEnum = (EyeColor)userNumber;*/

getEyeColorDetails(Brown);


cin.get();
}

CodeBeauty
Автор

You are appreciated. I don't think I would be able to passing my C++ module without you.

richardchinomona
Автор

I love your videos Saldina, much better than any other I could find

dundyd
Автор

Yess, was waiting for this. Your videos are great!

milkamilkica
Автор

Your accent is so understandable and easy to follow. Thanks a million ❤

omleen
Автор

Thank you for making this video,
I really appreciate it. 💯👍🏻

alec_almartson
Автор

Absolutely great! Your videos are amazing. Enums still give me lots of questionnarks, but you deleted some of them!
Great Videos!
Keep it up! :)

theloveoflife
Автор

Thankyou so much! I love your videos, you explain everything so clearly and in a simple fashion. I have learnt so much from you! Thankyou!

moodyshah
Автор

Always good content and presentation style. I always learn things from your videos. You've asked about a complete SQL class/series a couple times--yes from me.

neilcampbell
Автор

After watching this video I finally could understand the use of enums. Thanks for sharing your knowledge.
Regards from Brazil.

GiorgiBastos
Автор

I really enjoy and learn a lot from your videos. Thank you Code beauty.

mosopefoluwaadebawojo
Автор

I'm your biggest fan bcz your videos changed my life. I was depressed and couldn't see anything positive and interesting to do with my life until I started watching your videos. now I feel that I'm making progress every day and cant wait for every new video that you publish. love you SALDINA 🌹🌹🌹

gollygobih
Автор

Your videos are better than whatever is available on YouTube.
Thanks for sharing ur knowledge.
Please make videos about rtti

savansanghavi
Автор

Hi .. I'm a self taught programmer for embedded hardware .. Feeling playful; my eye colour changes with my mood - 12 today :). I came here to refresh knowledge of Static variables. BYW .. my two fav. teachers are you and David Malan (CS50) .. Thanks much.

peterlaidlaw
Автор

tysm for ur videos regarding programming it's helping me and ofc other's alot i'm enjoying alot :)

jaspreetahir
Автор

Thank you Saldina♥️ This was really helpful, and it's 2 btw😁

-_-
Автор

You make me understand every concept in c++, I love you so much I'm so grateful🥰🥰😍😍😍

dandon.
Автор

This video is a masterpiece! Congratulations, Saldina, it helped me a lot!

ycgxehy
Автор

Always love your teaching styles ❤️❤️❤️❤️❤️❤️❤️

dishant
Автор

Amazing video. Didn’t get this concept when explained in college. You made it so much easier to understand.
EyeColor myEyeColor = (EyeColor) 1;
If (EyeColor == 1) {likeVideo();}
Else {likeVideo();}

ammaarsaadat
welcome to shbcf.ru