The Difference Between Plain Enum And Enum Class In C++?

Поделиться
HTML-код
  • Опубликовано: 13 янв 2025

Комментарии • 43

  • @jeribertopower7611
    @jeribertopower7611 3 года назад +7

    An explanation online felt confusing but now is crystal clear. Thanks!

    • @CppNuts
      @CppNuts  3 года назад +1

      Great to hear!

  • @SkSafowan
    @SkSafowan 3 месяца назад

    Simple to the point
    Excellent tutorial my friend

  • @tincustefanlucian7495
    @tincustefanlucian7495 7 лет назад +7

    Thanks, I just learned something new

  • @spicytuna08
    @spicytuna08 6 лет назад +1

    valid point. this video just answered a remark i have made in the previous video.

  • @mastermax7777
    @mastermax7777 Год назад

    excellent tutorial. provides very good reasons to always use enum classes instead of regular enums

  • @kutalpdilber8815
    @kutalpdilber8815 3 года назад +1

    exactly what i wanted to know, elaborately explained, thanks.

    • @CppNuts
      @CppNuts  3 года назад

      Glad it was helpful!

  • @spicytuna08
    @spicytuna08 6 лет назад +3

    thanks for clarifying this important point.

    • @CppNuts
      @CppNuts  6 лет назад

      You are welcome!!

  • @Byynx
    @Byynx 5 дней назад

    Cppnuts always making the difference.

  • @MrKreidel
    @MrKreidel 6 лет назад +8

    Another important advantage of enum classes is that you can specify its size:
    enum class Colors : char { red, green, blue}
    That is really handy for memory limited environments such as embedded systems.

    • @manuelmueller7243
      @manuelmueller7243 4 года назад +8

      you can do the same for regular enums

    • @MrKreidel
      @MrKreidel 4 года назад

      @@manuelmueller7243 how so? Are you referring to compiler features? Professionally I would never go for such lock-in.

    • @treyquattro
      @treyquattro 4 года назад

      @@MrKreidel it's in the spec

    • @MrKreidel
      @MrKreidel 4 года назад

      @@treyquattro Can you point me to where the spec defines that? I still think it doesnt. Also, I don't see how I could syntactically formulate this in code.

    • @treyquattro
      @treyquattro 4 года назад

      @@MrKreidel dude. en.cppreference.com/w/cpp/language/enum

  • @apurvkumar1808
    @apurvkumar1808 4 года назад +1

    since enum classes are full fledged classes we should be able to overload the operators for them ???

  • @AakashKumar-gl2fk
    @AakashKumar-gl2fk 5 лет назад +1

    So much knowledge in a single video

  • @angelopapaya4692
    @angelopapaya4692 Год назад

    How to use cin, enum classes and switch cases?
    I would like to that integer which i put from keyboard to be something from enum

  • @tchovosky
    @tchovosky 2 года назад

    Great video!

  • @dishantkumawat7508
    @dishantkumawat7508 3 года назад

    Very clear explanation Thanks

    • @CppNuts
      @CppNuts  3 года назад

      Glad it was helpful!

  • @RachitGarg900
    @RachitGarg900 3 года назад

    Very good explanation.

    • @CppNuts
      @CppNuts  3 года назад

      Glad it was helpful!

  • @batoolazzam6422
    @batoolazzam6422 2 года назад

    thanks for this video
    I have an exam on this tomorrow and my professor never explained it in depth

  • @madhurimaburagohain7438
    @madhurimaburagohain7438 4 года назад

    Thank you for explaining so well. Please make videos on boost library.

    • @CppNuts
      @CppNuts  4 года назад

      Thanks man i may try..

  • @LuvableRawrRawr
    @LuvableRawrRawr 3 года назад

    This is the best explanation ty!

    • @CppNuts
      @CppNuts  3 года назад

      Glad it was helpful!

  • @brazo98
    @brazo98 5 лет назад +1

    Thx a lot you explain this very magic like thinking simple SJ! 🖖🏻🖖🏻🖖🏻

    • @CppNuts
      @CppNuts  5 лет назад +1

      Thanks alot, it motivates.

  • @nssravitejalakkoju3909
    @nssravitejalakkoju3909 6 лет назад

    can we compare a string and a variable in enum class or enum

  • @kudoamv
    @kudoamv 7 лет назад +3

    I don't know why but in MSVC even after putting int green = 100; it still compiled .
    Maybe it's a runtime error ? Sir can you please help ?

    • @CppNuts
      @CppNuts  7 лет назад +1

      Shinichi Kudo it should not compile please check your green spelling or you might have done something else.

  • @treyquattro
    @treyquattro 4 года назад +1

    People {good, bad} should be a fundamental type!

  • @haos4574
    @haos4574 5 лет назад +2

    wow, didn't know that

  • @Gundyr54
    @Gundyr54 26 дней назад

    thank youuuuuuuuuuuuu

  • @sebby5336
    @sebby5336 21 день назад

    This was amazing. wth