No video

ENUMS in C++

  Рет қаралды 387,061

The Cherno

The Cherno

Күн бұрын

Пікірлер: 254
@deepakprakash8940
@deepakprakash8940 4 жыл бұрын
Some of the best videos are made just after sleep.
@bobas5948
@bobas5948 3 жыл бұрын
this guy is one of those 5% of youtubers who actually deserve a patreon. he puts in effort to make C++ hell feel like barbeque grill.
@NeoKailthas
@NeoKailthas 3 жыл бұрын
and your brain is for dinner lol
@soulninjadev
@soulninjadev 3 жыл бұрын
nah it's not hell, its just on the harder side of programming, where only smort ppl are allowed
@puppergump4117
@puppergump4117 2 жыл бұрын
@@NeoKailthas Braaaaiiinnsss
@puppergump4117
@puppergump4117 2 жыл бұрын
@@soulninjadev Don't be all uppity, there's a fine line between using a bunch of libraries and not getting anything done, and either one has no room for calling yourself smort
@ashiinsane90
@ashiinsane90 7 жыл бұрын
hands down the best programming channel on youtube, fast straight to the point thank you!
@quaffie
@quaffie 4 жыл бұрын
and hes hot
@user-dh8oi2mk4f
@user-dh8oi2mk4f 3 жыл бұрын
@@quaffie lol
@zanesnep
@zanesnep 2 жыл бұрын
@@quaffie you right
@aquibshaikh8611
@aquibshaikh8611 4 жыл бұрын
Cherno after waking up... "lets make a video on C++"
@mmaranta785
@mmaranta785 3 жыл бұрын
Dude never combs his hair
@forhadrh
@forhadrh 3 жыл бұрын
😄😄
@leixun
@leixun 4 жыл бұрын
*My takeaways:* ENUMS is a way to name values 0:34
@onigumo
@onigumo 4 жыл бұрын
闭嘴,没人关心
@ganjalfthegreen5312
@ganjalfthegreen5312 4 жыл бұрын
@@onigumo why?
@chirathpansilu5782
@chirathpansilu5782 3 жыл бұрын
And also to define a 'set' of values
@dimitar.bogdanov
@dimitar.bogdanov 3 жыл бұрын
@@onigumo gtfo
@antonkovachev9181
@antonkovachev9181 Жыл бұрын
@@dimitar.bogdanov Kaji mu go bacho Dimo
@Plasticcaz
@Plasticcaz 7 жыл бұрын
I discovered enum classes the other day, and I was so happy. Classic enums are kind of annoying when they leak into the current namespace.
@Ranakade
@Ranakade 5 жыл бұрын
Finally! A straight to the point explanation of enum! Subscribed!
@zsdanix
@zsdanix 6 жыл бұрын
Actually you can avoid the confusion with distingiushing the two "Error" like Log::Level::Error
@petrvaganov
@petrvaganov Жыл бұрын
Or use ERROR
@salman2972
@salman2972 7 жыл бұрын
Can you make a video for cmake...?
@vertigo6982
@vertigo6982 5 жыл бұрын
He would have to make a couple videos on cmake.. one video is never enough and barely would cover an intro to cmake.. cmake has decent documentation though which I find is better than video hunting because.. not every video is using your IDE/build system, or OS.. so there's different configs to learn depending on what youre building on and building for. I had a difficult time finding a video using cmake in linux to build something to put on git so I can clone it on my windows system and build it... Then I had to narrow it down more to finding videos on using cmake in linux in kdevelop... I quickly learned.. skip the videos.. just dig into the docs.
@master_spike
@master_spike Жыл бұрын
One of my favorite usages of Enums is as a function template parameter, with constexpr if statements if i need a function to do something *slightly* different depending on some options. It eliminates a lot of conditional instructions from compiled code while cutting down on duplicate written code.
@marcandrei8061
@marcandrei8061 2 жыл бұрын
not great for someone who doesn't have a clue but as someone who knows c and is trying to move to c++ I really just need to learn oop so I'm thankful for his explanations that are more sophisticated than other youtubers that generally stop at explaining how to compile a program or write a variable or a function.
@foomoo1088
@foomoo1088 2 жыл бұрын
It would be awesome to have an updated version of this coving enum class as you mentioned, but also addressing the pesky issue in C++ enumerated regarding serialization and mapping to string names. (E.g. there’s a use-case for having ascii serialized assets which have enum values serialized as string names). Use of enum as bitfields (flags) is also another useful side topic. Thanks Cherno!
@casperes0912
@casperes0912 3 жыл бұрын
Using 2^n for enum values means you can often do some bitwise AND/OR operations cleverly. Like if A = 1, B = 2, C = 4. If it's possible for two to be "active" at once, A+C = 5 which means if you & it with A it'll == A and if you & it with C it'll == C
@ChaosB7ack
@ChaosB7ack 2 жыл бұрын
Those are called flags, I've never seen them declared as enums tbh. Most times they are #defined since they are very much used in shared headers
@casvanmarcel
@casvanmarcel 7 жыл бұрын
Very educational, you are a fantastic teacher Cherno. Waiting for the OpenGL series! Thank you so much for making these
@DavidBChannel
@DavidBChannel Жыл бұрын
My lecturers made me forget what it's like to understand a coding lesson, thanks for reminding me! lmao
@-TheBugLord
@-TheBugLord 3 жыл бұрын
Thank you so much. My 122 professor started glossing over enums with operator overloading, assuming we already knew them, when my 121 teacher never taught them
@ghostravenstorm385
@ghostravenstorm385 2 жыл бұрын
"The error doesn't actaully work and gives us an error" I don't know why I chuckled at that statement.
@darimuhittin
@darimuhittin 6 ай бұрын
You need to be in every university in every country .
@Tupiniviking_de_osasco
@Tupiniviking_de_osasco 2 жыл бұрын
I recently started watching your channel, even though I'm subscribed long time ago. It's amazing how your videos are elucidating even if you don't even to struggle doing it. Cheers!
@bigmamatristana677
@bigmamatristana677 5 жыл бұрын
Great videos, this was my second time watching your static compilation and it made complete sense.
@subhamprasad1373
@subhamprasad1373 3 жыл бұрын
i started learning c++ this year , and i really thank you , your videos helped a-lot ,and please continue to keep adding new videos
@DashwoodIce9
@DashwoodIce9 4 жыл бұрын
Great tutorials man, thanks! And the hair too, love it 😂
@gabrielrosewood3257
@gabrielrosewood3257 2 жыл бұрын
Damn, Thank you! Your vids are short, fast, and to the point. Thank you again keep up the good work!
@krec348
@krec348 7 жыл бұрын
One more excellent tutorial. This series are just perfect for anyone that wants to learn C++. Thank you :P
@divyabhoi9584
@divyabhoi9584 4 жыл бұрын
When you write Log::LevelWarning, does it mean that LevelWarning is a static variable belonging to the Log class?
@GenericPhantom1
@GenericPhantom1 Жыл бұрын
Enums are integers behind the scenes. If you have a set of values you want to represent numerically you use enums
@Special4ce293
@Special4ce293 2 жыл бұрын
So far so good, I have 99% identical code to what you wrote, (just renamed a few things but kept everything consistent... However, I am getting a 'C26812' Warning. The enum type 'Log::LogLevel' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).
@UNRELATIVE
@UNRELATIVE Жыл бұрын
Thanks,The Cherno.
@batabatonica
@batabatonica 6 жыл бұрын
Man these are soo useful, i love this series
@Delemaroth
@Delemaroth 2 жыл бұрын
Convention for all other cases with Enumerators is to completely capitalize the words used in them. is that not the case in c++ development?
@houaxiong616
@houaxiong616 4 жыл бұрын
OMG! This makes so more sense! Thank you!
@rcookie5128
@rcookie5128 7 жыл бұрын
Once again I thought I knew everything about enums, but never knew you can explicit type the enum neither that you can directly access enums from classes without having to get the enum itself first (so Log::Error)
@rcookie5128
@rcookie5128 7 жыл бұрын
btw love the shaggy hair style!! :D
@heksogen4788
@heksogen4788 5 жыл бұрын
Example code would be great for each video, especially like this.
@yeadatwunyt8004
@yeadatwunyt8004 2 жыл бұрын
Just unlocked so much for me in my coding education! thank you! thank you! thank you!
@saravana8016
@saravana8016 6 жыл бұрын
I love your hairstyle
@Steve-gi2yj
@Steve-gi2yj 5 жыл бұрын
@TheChernoProject, big thank you for the videos, learning a lot more than i ever have with c++ :)
@puppergump4117
@puppergump4117 2 жыл бұрын
sfml groups enums into their own namespaces, which is one of the better ways I've seen them grouped
@user-fn3ok4dm7f
@user-fn3ok4dm7f 3 жыл бұрын
Thank's these tutorials help me alot!
@ashereinhorn
@ashereinhorn 2 жыл бұрын
Love the videos. i’ve been binging them. You’ve started looking very tired here! perhaps it’s that EA job you eventually quit. I can certainly relate! Glad you’re in a better place now!
@georgeryan1437
@georgeryan1437 5 жыл бұрын
Sorry if this question is stupid, but does the indentation on the if statements, somehow make an exemption for curly brackets?
@georgeryan1437
@georgeryan1437 5 жыл бұрын
@Peterolen Yes, but that doesn't explain why their is no curly brackets.
@unicorns537
@unicorns537 4 жыл бұрын
Oh my gosh it's me on a different account. I thought I'd watched this vid before, nonetheless it's always beneficial to rewatch a Cherno video.
@Jan_Jan_
@Jan_Jan_ 2 жыл бұрын
This channel is fantastic! 👏
@lessiom4255
@lessiom4255 7 жыл бұрын
Keep it up, fantastic video as always!
@AboutVelvet
@AboutVelvet 3 жыл бұрын
Now that's a well-made video.
@CZBorda01
@CZBorda01 6 жыл бұрын
These are amazing tutorials! Great job. I got really excited on C++ because of them. Are there any similar tutorial on youtube about C# or Java?
@fangornthewise
@fangornthewise 2 жыл бұрын
I second the question but towards Javascript or Solidity.
@w3w3w3
@w3w3w3 4 жыл бұрын
Thanks for another great video Cherno!
@superpb600
@superpb600 6 жыл бұрын
IDK why the conventions doesn't say to use full upper case in case of constants, so would be 'ERROR' just like Java, then those issues would not happen...
@MrCoder101
@MrCoder101 6 жыл бұрын
Better yet, use enum class and forever avoid conflicts
@utoothheartyeight
@utoothheartyeight 4 жыл бұрын
Cherno, what IDE are you using in your presentations?
@msidc1238
@msidc1238 4 жыл бұрын
He's using visual studio.
@utoothheartyeight
@utoothheartyeight 4 жыл бұрын
@@msidc1238 Thank you. I apologize for asking since all I had to do was go way back to one of Cherno's earlier videos and he more than answered the question. Bad of me.
@ahmedghallab5342
@ahmedghallab5342 Жыл бұрын
شكرا جزيلا ♥️♥️ thank you
@Raul11madrid1
@Raul11madrid1 7 жыл бұрын
Keep going brother your videos is great and very helpful thanks
@supersonic1240
@supersonic1240 3 жыл бұрын
Thanks to Cherno I started to actually like C++
@sushilarya2005
@sushilarya2005 3 жыл бұрын
Explained perfectly nice
@christosioannou9990
@christosioannou9990 2 жыл бұрын
Can you do a video of using shortcuts when using visual studio …e.g. select a line, select a section, select multiple lines, search etc!! Thanks 🙏🏻
@JiwonSong95
@JiwonSong95 6 жыл бұрын
It helped me a lot but bit fast for non native english speaker haha
@90966689
@90966689 4 жыл бұрын
I can't see his vedio on normal speed. I always decrease speed and used subtitle
@darkushippotoxotai9536
@darkushippotoxotai9536 4 жыл бұрын
I understand him but seriously, you can't code as fast if you are a beginner. I have to pause the vid. Each time he does something.
@brunocalhiari976
@brunocalhiari976 3 жыл бұрын
I know this comment is 2 years old already but, for you or anyone facing this problem...just keep practicing watching more and more videos in English, and also try to see vídeos of the person talking directly to the camera, it is easier to understand and make you get used...and don't quit studying English until you start to understand things, also try to talk to people in English, even by text will improve very much your vocabulary....just keep pushing, and eventually you'll be talking in English without even realizing, because it is a very simple language (my native is Portuguese)...another thing that I've done was changing every electronic device I use to English, and start to read every book in English instead of Portuguese, also, another big thing was start searching in Google in English...well, I hope you're not having problems with this anymore, but if you still do, this is what I did and it worked...
@bartichaut6957
@bartichaut6957 3 жыл бұрын
@@brunocalhiari976 Thanks for your comments. I'm french but i can understand what he said with the subtitles activated.
@Xx_McJasper_xX
@Xx_McJasper_xX 3 жыл бұрын
Nice and clean, as usual. Enums aren't that interesting, but I'm glad to see you described them as basically just compiler-enforced sugar.
@avinashmehtadelhi
@avinashmehtadelhi 3 жыл бұрын
please do post a video on enum class. thanks
@PerchEagle
@PerchEagle 5 жыл бұрын
thanks dude, I learned that I can control the size of enum members :)
@audreylee8554
@audreylee8554 3 жыл бұрын
what's the font do you use? I cant find a good font in VS...
@drinixgames7271
@drinixgames7271 7 жыл бұрын
Hey Ian I think you should've talked about enum classes, the addition of enums in C++14? I think, enum classes change a lot of stuff about enums, so they are not just plain integers(well technically they are but you cannot compare two enums of different class types!
@TheCherno
@TheCherno 7 жыл бұрын
As I mentioned (twice), enum classes will be covered in a future video. Also it's *Yan
@drinixgames7271
@drinixgames7271 7 жыл бұрын
TheChernoProject excuse me sir, also your videos are being really helpful for me :).
@TheCherno
@TheCherno 7 жыл бұрын
No worries, glad you're enjoying them :)
@batman_1st
@batman_1st 6 жыл бұрын
Can you please do a video on template class?
@nanayang3736
@nanayang3736 Ай бұрын
wanna know if the the enum classes video has been out now or not
@mtraven23
@mtraven23 5 ай бұрын
the way he wrote the enum ref in the main class (Log::Level) -- that looks like static member addressing, I see no static keyword on the enum, does that mean they are static by default?
@kenamreemas3295
@kenamreemas3295 5 жыл бұрын
That hair though! XD
@smitadeshpande6525
@smitadeshpande6525 5 жыл бұрын
hi you can use refactor feature of visual studio for renaming a variable at multiple places automatically.
@jscorpio1987
@jscorpio1987 5 жыл бұрын
I think he was doing it manually for the purposes of this tutorial so that we could see what’s going on more easily.
@alex.ander.bmblbn
@alex.ander.bmblbn 3 жыл бұрын
a great example of how you might use it in real life is how you want to use boolean type in C: instead of having an integer taking two values, you go with typedef enum { false, true } bool; and there you go, you can use your good old true and false
@alex.ander.bmblbn
@alex.ander.bmblbn 3 жыл бұрын
@Artem Katerynych the same way you can say that C has classes if you define a class as a structure. Im saying ORIGINALLY, without any additional includes
@autumnleaf8483
@autumnleaf8483 3 жыл бұрын
This is something in Roblox Studio(game development platform for Roblox, also learning that and as well as C++) but ENUMs work the same way how it works in Roblox Studio scripting.
@autumnleaf8483
@autumnleaf8483 3 жыл бұрын
Probably because Roblox is made of C++ and Lua.
@computerprogrammer7942
@computerprogrammer7942 3 жыл бұрын
Roblox is made from C and uses Lua
@computerprogrammer7942
@computerprogrammer7942 3 жыл бұрын
Roblox made their enums a bit different
@autumnleaf8483
@autumnleaf8483 3 жыл бұрын
@@computerprogrammer7942 Umm... well uh, Enums are strings with a number as their value... same goes for Roblox, except that there are Enums for Enums. Like nested Enums.
@autumnleaf8483
@autumnleaf8483 3 жыл бұрын
If I am wrong sorry, it's been a over a month nice I learned or practiced C++
@Maceta444
@Maceta444 2 жыл бұрын
5:40 Aren't we breaking encapsulation with this?!
@bradcasper4823
@bradcasper4823 2 жыл бұрын
5:40 Now you have to use this: log.SetLevel(Log::Level::LevelWarning);
@amolkarande2831
@amolkarande2831 6 жыл бұрын
I would like to suggest that to add an enum "count" to track the number of enums as a good practice. Correct me if I am wrong.
@1matroska
@1matroska 4 жыл бұрын
Thanks again!
@odrabil123
@odrabil123 6 жыл бұрын
I’ve watch some of your videos, they are all great, especially the examples. Can you please tell me what IDE you use?
@DominicVictoria
@DominicVictoria 3 жыл бұрын
I’m just watching this again for my sanity because I’m getting tired of JavaScript tutorials on yt. I wish someone would have something well put up series like this.
@user-ug9sh3vp4n
@user-ug9sh3vp4n Жыл бұрын
how do you have multiple in main() functions in one project
@froycardenas
@froycardenas 5 жыл бұрын
One simple question: why a statement inside an enum type variable is not finished with a semicolon like any other statements in the body of a block of instructions?
@arnavsharma3880
@arnavsharma3880 3 жыл бұрын
Damn legend. ❤️ 👍
@pablocastaneda4021
@pablocastaneda4021 2 жыл бұрын
Super vid
@floppy-disko2378
@floppy-disko2378 4 жыл бұрын
C++ guidelines or whatever were updated in 2019 with Enum.3 so now using plain "Enums" will give a warning code C26812.
@jul8803
@jul8803 2 ай бұрын
I get an error with: Log log; log.SetLevel(log::LevelError); but the following works: Log log; log.SetLevel(log.LevelError);
@ahmadverse4101
@ahmadverse4101 6 жыл бұрын
Well i have a question that why did you : unsigned char with enum? I didn't understand the size terminology.
@ckkitty
@ckkitty 5 жыл бұрын
Unsigned means that it will not have negative values, and char is an 8 bit integer char: -127 to 128 unsigned char: 0 to 256
@chrisy.703
@chrisy.703 5 жыл бұрын
really enjoy ur videos and learn quite a lot new things. can you make a vieo about how to develop a project on vsc? VSC is getting pretty popular now. Thank you
@kopuz.co.uk.
@kopuz.co.uk. 4 жыл бұрын
using VSC for c++ is like taking 10 steps backwards.
@brunocalhiari976
@brunocalhiari976 3 жыл бұрын
@@kopuz.co.uk. of course visual studio is far more complete when it supports a language, but it does not top the vscode text edit features, also, if you set it properly, vscode will deliver a experience pretty near of what you'd get on visual studio
@loganayers7851
@loganayers7851 3 жыл бұрын
Jesus... I was about to make fun of your hair then you went and explained EXACTLY the fuck I needed to know... Like perfectly... You're hair remains off limits as long as you continue to destroy these tutorials. Thanks bruh.
@ItsTheJackpot
@ItsTheJackpot 7 жыл бұрын
Really liking these tutorials, I was told I am going to get C++ classes in the second half of the coming year, so this gives me a nice headstart. May I ask though, is it me or is the footage a bit gray?
@hamzamameche3893
@hamzamameche3893 3 жыл бұрын
I still don't get when to use the dot operator and when to use the scope operator, I get that because enum is a sort of const static ? that you access it through the scope operator?
@imadvurkadinohinto
@imadvurkadinohinto 4 жыл бұрын
many thanks to this pretty guy!
@anthonyhalim926
@anthonyhalim926 5 жыл бұрын
Can we modify enums somehow for non-integer hard-coded values? Like string, for example? Help much appreciated.
@oleholgerson3416
@oleholgerson3416 6 жыл бұрын
great videos, keep it up. although I watched so many videos I still can‘t figure out what animal is sitting on his head...
@shreeharshas6893
@shreeharshas6893 3 жыл бұрын
which is the compiler you are using??
@adrianoldchannel2494
@adrianoldchannel2494 6 жыл бұрын
This is good stuff.
@BrandonAB
@BrandonAB 6 жыл бұрын
Brilliant.
@davidboygenius6843
@davidboygenius6843 4 жыл бұрын
Do a video on File Stream I/O for C++
@Byynx
@Byynx 2 жыл бұрын
How at 6:55m is possible to pass an arg by only writing Log::LevelError sinse neither Log class or Levelerror are static ?
@puppergump4117
@puppergump4117 2 жыл бұрын
I've been using cpp for a while and I've never used the static keyword. My best guess is that the enum values are only scoped to the class, not the enum itself.
@ncky2431
@ncky2431 4 жыл бұрын
How can you have log and main which both have a main function at the same time and still execute the right main function? Also when I try to remove the main function I dont want to execute I just get a bunch of linking errors which I dont know how to resolve.
@kazirojanarahaman8131
@kazirojanarahaman8131 4 жыл бұрын
When you create an object with an enumeration as a member data, do you have to set the enumeration to something or will it give a random value automatically?
@ravisankar6779
@ravisankar6779 6 жыл бұрын
Hi all, I didn't understand one thing.Can anybody explain specifying ": data type" after the enum name in the example (1st example) ??
@eliaswilliam1337
@eliaswilliam1337 2 жыл бұрын
Whats the difference of using an enum and just #define levelerror 0 for example?
@noooeels367
@noooeels367 7 жыл бұрын
Jaaaay, video!
@henrycormen3805
@henrycormen3805 7 жыл бұрын
please talk about template coding , thanks!!!
@AbdulMoiz-ho8rx
@AbdulMoiz-ho8rx 2 жыл бұрын
great
@fedvgo
@fedvgo 3 жыл бұрын
is there a way to print the name of the enum you choose so error =0 is there a way to print just the name instead of the int
@jakubhorak636
@jakubhorak636 5 жыл бұрын
I prefer using enum class. You dont have to care about conflicts.
@serkanozturk4217
@serkanozturk4217 Жыл бұрын
Personal notes: - enum is enumerated integer at the end of the day.
Constructors in C++
6:58
The Cherno
Рет қаралды 420 М.
POINTERS in C++
16:59
The Cherno
Рет қаралды 1 МЛН
ROLLING DOWN
00:20
Natan por Aí
Рет қаралды 10 МЛН
ISSEI & yellow girl 💛
00:33
ISSEI / いっせい
Рет қаралды 23 МЛН
طردت النملة من المنزل😡 ماذا فعل؟🥲
00:25
Cool Tool SHORTS Arabic
Рет қаралды 15 МЛН
Static for Classes and Structs in C++
9:12
The Cherno
Рет қаралды 349 М.
Templates in C++
17:58
The Cherno
Рет қаралды 587 М.
ENUMS in every programming language (All you need to know)
24:38
lvalues and rvalues in C++
14:13
The Cherno
Рет қаралды 311 М.
How to Write a C++ Class
11:32
The Cherno
Рет қаралды 408 М.
Should you learn C++?? | Prime Reacts
20:29
ThePrimeTime
Рет қаралды 350 М.
Inheritance in C++
8:00
The Cherno
Рет қаралды 385 М.
C++ Tutorial:  enumerated data types [enums]
16:38
Professor Hank Stalica
Рет қаралды 1,5 М.
Dynamic Arrays in C++ (std::vector)
14:14
The Cherno
Рет қаралды 377 М.
ROLLING DOWN
00:20
Natan por Aí
Рет қаралды 10 МЛН