Learn C++ With Me #12 - Switch Statement

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

КОМЕНТАРІ • 28

  • @satvikreddy8662
    @satvikreddy8662 3 роки тому +23

    Just a note for this video that I think is important to point out. Apart from the switch statement being more elegant, it is also more efficient, especially when you have lots of cases. The reason being, a switch statement is generally implemented with a hash table or a similar data structure, giving you (ideally) an O(1) time complexity to get through the switch. With an if statement, worst-case scenario, you have to compare your variable to every single case, leaving you with an O(n) time complexity, n being the number of cases, which can be slow.

    • @rmt3589
      @rmt3589 11 місяців тому +2

      Hence why I'm here. Someone I loathe refuses to use these, and has pages of if/else. I want to be nothing like him, so I'm doubling down.

  • @QuaternionPhysics1
    @QuaternionPhysics1 3 роки тому +5

    Can’t wait for the more advanced stuff! Amazing series so far, probably the best 👀
    Keep it up, Tim!

  • @paulzupan3732
    @paulzupan3732 3 роки тому +6

    There's one drawback to the switch statement that's quite important, and that is the fact that the cases in the statement must be compile-time constants. So if you get errors that a variable is not usable in a constant expression or the compiler complains about a call to a non-constexpr function, that's why.

  • @thatdude8368
    @thatdude8368 2 роки тому +1

    Like how you go very in depth to everything em explain everything all the way through

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

    I have finally got ther confirmation for vectors, pointers and refferences, which is what I was waiting for in the series

  • @seireiart
    @seireiart 3 роки тому +20

    Finally, the tutorial YandereDev need to watch the most LMAO XDD

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

    I was waiting for new c++ lesson 😁😁😁

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

    Switch statements create jump tables when they are compiled into machine code, for a huge list that, let's say is running 165 times a second in a list of 1000 items, this performance improvement can be EXTREME

  • @Gilmore_Coding
    @Gilmore_Coding Місяць тому

    Nice this one is just like the match case in python

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

    Thanks for you content Tim ;)

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

    My education system failed, this youtube man excelled

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

    What chair are you using dude?

  • @user-sy3ny1sz2w
    @user-sy3ny1sz2w 3 роки тому +6

    Switch statement can't use string a.k.a "std::string" and C string a.k.a "const char*" as expression.

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

    yes tim!

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

    ty

  • @keshav.mishra
    @keshav.mishra 3 роки тому

    Tim! Which degree are you doing Bsc (computer science) or Btech (computer science)

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

    How much focus will you be putting on creating graphics or seperate windows in future videos?

  • @lemahtab
    @lemahtab Рік тому

    So, this is similar to SQL's CASE statement, right? Don't need it but is better than IF ELSE in some cases.

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

    Thank ya)

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

    Can you make more pygame and tutorials please in python.

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

    pls make video 5 ideas for game in pygame

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

    Cool

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

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

    huzzah

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

    Bro can u please explain about power shell please bro i need it please🙏🙏🙏🙏

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

      What are you looking to do with PS

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

    2nd