C++ variable scope explained 🌎

Поділитися
Вставка
  • Опубліковано 5 вер 2024
  • #local #global #variables
    Local and global variable scope in C++ tutorial example explained

КОМЕНТАРІ • 12

  • @BroCodez
    @BroCodez  2 роки тому +8

    #include
    int myNum = 3; //global
    void printNum();
    int main()
    {
    int myNum = 1; //local
    printNum();
    std::cout

  • @FrederikWollert
    @FrederikWollert 5 місяців тому +2

    I really like your C++ series. Keep it up. Please make more C++ Videos. So, let's defeat the UA-cam algorithm.

  • @yahyaarfaoui8526
    @yahyaarfaoui8526 Рік тому +4

    std::cout

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

    Yu the best ❤️

  • @oximas-oe9vf
    @oximas-oe9vf Рік тому +3

    what do you mean by " "pollutes" the global namespace " ?

    • @BurninVinyl
      @BurninVinyl 5 місяців тому +1

      Re-watch about namespace. In C++ global variables can potentially pollute the namespace by making it more difficult to disambiguate between variable names and other entities with the same name. This can lead to code that is harder to read and maintain. It's generally recommended to use namespaces or other scoping mechanisms to avoid this issue.

  • @gamsterilyass2952
    @gamsterilyass2952 3 місяці тому

    ❤ ❤

  • @Nightmare-bo7xi
    @Nightmare-bo7xi Місяць тому

    so what is printNum and how is it related to myNum

  • @parpaperchimp
    @parpaperchimp 6 місяців тому

    #include
    int P =3.14;
    int main(){
    std::cout

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

    yo

  • @wlsedlacek
    @wlsedlacek Рік тому +1

    comment = rand(random_comment) % 100;

  • @artemzakharchuk2842
    @artemzakharchuk2842 10 місяців тому +2

    std::cout