C++ Programming Tutorial 35 - Switch Statement and Enum

Поділитися
Вставка
  • Опубліковано 2 лют 2025

КОМЕНТАРІ • 42

  • @alexplaytop
    @alexplaytop 10 місяців тому +1

    I love music at the end of the show!

  • @mytech6779
    @mytech6779 3 роки тому +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.

  • @KynesisCoding
    @KynesisCoding 4 роки тому +8

    nearly punched my computer if it wasn't for you, thanks for saving me $$$

  • @8kigana
    @8kigana 5 років тому +3

    Caleb are you using visual studio code c++? I asked because I don't know how to run it even after I installed it.

  • @WalkthroughCentral10
    @WalkthroughCentral10 5 років тому +4

    Excellent videos! Keep it up man!

  • @Sapphireeyes104
    @Sapphireeyes104 4 роки тому +1

    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.

  • @deviltube6205
    @deviltube6205 3 роки тому +1

    is it possible to take the case as input by user using cin>>Season?

  • @olliveraira6122
    @olliveraira6122 4 роки тому +2

    How do you fetch enums name as string?

  • @SweaterSwagg
    @SweaterSwagg 4 роки тому +2

    Great tutorial, thank you!

  • @guitarhax7412
    @guitarhax7412 5 років тому +5

    Boom, next!

  • @johnnikay3359
    @johnnikay3359 3 роки тому +2

    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?

  • @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

  • @alexissuarezalvarez5622
    @alexissuarezalvarez5622 4 роки тому +1

    hi, how come c ++ can interpret the word "season"?

    • @Austin1990
      @Austin1990 4 роки тому +3

      Because he is defining it as an enumeration, like how C++ would recognize names of classes that you create.

  • @engineeringjoe
    @engineeringjoe 5 років тому +2

    Which ide is this?

    • @furiosarana1857
      @furiosarana1857 5 років тому +3

      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.

  • @oengkimsour812
    @oengkimsour812 4 роки тому

    Thanks youu so much

  • @galihtanu
    @galihtanu 3 роки тому +1

    You make it simple. 👍

  • @Norogoth
    @Norogoth 4 роки тому +1

    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 років тому +1

    Celeb Curry is very close to 'Howard - Curry ' ;)

  • @sergiorome42
    @sergiorome42 2 роки тому +3

    the amount of times he said integrals :( bruh its integers

  • @erikhicks6184
    @erikhicks6184 2 роки тому

    This isn't Bucky??

  • @FranklinGaming23
    @FranklinGaming23 5 років тому +5

    You should use the header file #include so you can just type cout

    • @julioflores1849
      @julioflores1849 5 років тому +14

      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 роки тому +1

      @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 роки тому +4

      Dumbest comment ive ever red

  • @charlesmullen8024
    @charlesmullen8024 3 роки тому

    9:05 lol

  • @arworld8145
    @arworld8145 4 роки тому +1

    💖💖

  • @forhadrh
    @forhadrh 3 роки тому +1

    👍

  • @immortalsheggy
    @immortalsheggy 4 роки тому +1

    pog

  • @AlexanderWebster_
    @AlexanderWebster_ 4 роки тому +1

    Should have hit the 10 minute mark! More revss

  • @immortalsheggy
    @immortalsheggy 4 роки тому

    not a single most likely taken