C++ Programming Tutorial 35 - Switch Statement and Enum

  Рет қаралды 49,591

Caleb Curry

Caleb Curry

Күн бұрын

Пікірлер: 42
@alexplaytop
@alexplaytop 9 ай бұрын
I love music at the end of the show!
@KynesisCoding
@KynesisCoding 4 жыл бұрын
nearly punched my computer if it wasn't for you, thanks for saving me $$$
@mytech6779
@mytech6779 2 жыл бұрын
Fall through is actually the more useful feature of switch, eg if condition X requires actions 1,2,3 ; Y requires 2 and 3 ; and Z only needs 3. And you are not limited to integer cases, it will accept enumerable types. As with many things in life, just because you can't find the value in something doesn't mean that it doesn't have value to someone else. And this part is speculation as I haven't tested; but I can see the way that switch acts more like a lookup table rather than accepting complex expressions is likely a big performance advantage over complex if statement structures which require inline evaluation at every level. Sort of analogous to compiled verses interpreted source code.
@WalkthroughCentral10
@WalkthroughCentral10 5 жыл бұрын
Excellent videos! Keep it up man!
@Sapphireeyes104
@Sapphireeyes104 4 жыл бұрын
I was curious so I looked, and switch cases are pretty much identical in Game Maker Language. I haven't gone over switch cases in class yet, but I already knew what they functionally did. I wanted to peek ahead and see how complicated it was later, and then I got curious and looked at the GML equivalent.
@olliveraira6122
@olliveraira6122 4 жыл бұрын
How do you fetch enums name as string?
@guitarhax7412
@guitarhax7412 5 жыл бұрын
Boom, next!
@SweaterSwagg
@SweaterSwagg 4 жыл бұрын
Great tutorial, thank you!
@8kigana
@8kigana 5 жыл бұрын
Caleb are you using visual studio code c++? I asked because I don't know how to run it even after I installed it.
@johnnikay3359
@johnnikay3359 3 жыл бұрын
When I do this, I can only access the option that is initialized at the top (Season::Winter).
@PunmasterSTP
@PunmasterSTP 3 жыл бұрын
Did you write code in any of the other cases?
@sergiorome42
@sergiorome42 2 жыл бұрын
the amount of times he said integrals :( bruh its integers
@Artem_Kichaev2722
@Artem_Kichaev2722 9 ай бұрын
Ya, that bothered me too😂
@deviltube6205
@deviltube6205 3 жыл бұрын
is it possible to take the case as input by user using cin>>Season?
@Norogoth
@Norogoth 4 жыл бұрын
How the hell are you the guy who does the big Oracle series AND this?
@Norogoth
@Norogoth 4 жыл бұрын
This question is NOT rhetorical.
@42norbert
@42norbert 5 жыл бұрын
Celeb Curry is very close to 'Howard - Curry ' ;)
@alexissuarezalvarez5622
@alexissuarezalvarez5622 4 жыл бұрын
hi, how come c ++ can interpret the word "season"?
@Austin1990
@Austin1990 4 жыл бұрын
Because he is defining it as an enumeration, like how C++ would recognize names of classes that you create.
@oengkimsour812
@oengkimsour812 3 жыл бұрын
Thanks youu so much
@tejjmk
@tejjmk 5 жыл бұрын
could you still use switch case with enums when you're using a buffer and were comparing. For example if ((commandBuffer.compare(0, endOfVerb, "north") == 0) || (commandBuffer.compare(0, endOfVerb, "n") == 0)) right now i've got to do for all directions and it's a bit repeated
@engineeringjoe
@engineeringjoe 5 жыл бұрын
Which ide is this?
@furiosarana1857
@furiosarana1857 5 жыл бұрын
Technically it is just an editor called Visual Studio Code, not Visual Studio (without the Code) which is an IDE for C++. It is an open-source editor that allows for ide-like functionality with extensions you can install for almost every language. I can highly recommend it and prefer it over more feature rich but more complex IDE's like Visual Studio, Eclipse... . If you depend on refactoring a lot, VS Code might not be optimal. PS: the theme is called Solarized Light and i love it. Edit: Also has great SCM (Source Control Management = Git(Hub)...)
@funwithaiman
@funwithaiman 5 жыл бұрын
Hey Furiosarana! Thanks for the suggestions.
@erikhicks6184
@erikhicks6184 2 жыл бұрын
This isn't Bucky??
@galihtanu
@galihtanu 3 жыл бұрын
You make it simple. 👍
@charlesmullen8024
@charlesmullen8024 3 жыл бұрын
9:05 lol
@FranklinGaming23
@FranklinGaming23 5 жыл бұрын
You should use the header file #include so you can just type cout
@julioflores1849
@julioflores1849 5 жыл бұрын
FranklinGaming using namespace std; Is what you want
@iluvyunie
@iluvyunie 4 жыл бұрын
@Bo Bob I like this one, it's more specific so you don't just include a crazy amount of predetermined names, and basic programs only really need std::cout, cin, string etc
@a999g21
@a999g21 4 жыл бұрын
@Bo Bob when there are lots of namespaces being used, it can clarify. Say there was a namespace called orange and a namespace called pear. If both had a function called print, how would you know which was being executed. This would be fixed by always saying things like pear::print ect.
@iluvyunie
@iluvyunie 4 жыл бұрын
@Bo Bob a namespace is (I may be wrong here) a set of preprocessor statements that prefix your code to tell the compiler what library your language is coming from? As in I could create a namespace inside a header file called poop and in order to call functions from my poop I'd have to type everything as poop::whateverIcalledthefunctionImadeinsidethepoopheader So std:: is just a set of instructions a lovely bunch of people cooked into what we call the standard library. I'm sure someone could explain this way better but yeah, that's my understanding. It's just to tell the compiler where the words you're typing in there are defined, because in c++ every little detail has to be outlined properly to work.
@bingkysskiliwaax7941
@bingkysskiliwaax7941 4 жыл бұрын
Dumbest comment ive ever red
@arworld8145
@arworld8145 4 жыл бұрын
💖💖
@forhadrh
@forhadrh 3 жыл бұрын
👍
@AlexanderWebster_
@AlexanderWebster_ 4 жыл бұрын
Should have hit the 10 minute mark! More revss
@immortalsheggy
@immortalsheggy 4 жыл бұрын
not a single most likely taken
@immortalsheggy
@immortalsheggy 4 жыл бұрын
pog
@teasauce3608
@teasauce3608 4 жыл бұрын
gers
C++ Programming Tutorial 36 - Intro to Loops
8:03
Caleb Curry
Рет қаралды 46 М.
References in C++ Explained
14:21
Caleb Curry
Рет қаралды 105 М.
Switch IS NOT FASTER than if, (in C++)
11:39
Low Level Game Dev
Рет қаралды 57 М.
No BS Advice for Software Engineers
1:21:17
Caleb Curry
Рет қаралды 10 М.
C++ Tutorial:  enumerated data types [enums]
16:38
Professor Hank Stalica
Рет қаралды 2,4 М.
ENUMS in every programming language (All you need to know)
24:38
C++ Programming Tutorial 46 - Working with Arrays
10:21
Caleb Curry
Рет қаралды 101 М.
C++ Pointers - Finally Understand Pointers
15:56
Caleb Curry
Рет қаралды 222 М.
Learn C++ With Me #12 - Switch Statement
8:02
Tech With Tim
Рет қаралды 22 М.
C enums 📅
4:27
Bro Code
Рет қаралды 67 М.