What is "using namespace std" and why is it considered a BAD PRACTICE? C++ Programming Questions

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 มิ.ย. 2024
  • What is "using namespace std;" and why is it considered a bad practice?
    In this video I'll teach you about namespaces, and also explain one of the most common questions that beginners have when they start learning programming - What is using namespace std?
    📚 Learn how to solve problems and build projects with these Free E-Books ⬇️
    C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book
    Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook
    🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/
    Experience the power of practical learning, gain career-ready skills, and start building real applications!
    This is a step-by-step course designed to take you from beginner to expert in no time!
    💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
    Use it quickly, because it will be available for a limited time.
    👉 Download Visual Assist here: bit.ly/VisualAssistDownload
    (It improves Visual Studio experience by quickly identifying and fixing code errors)
    🎁 Create Modern Apps, 5x faster, with less code, Download FREE C++Builder Trial: bit.ly/CppBuilderFree
    ☕ If you've found my content helpful and would like to support me, you now have the option to buy me a coffee or a cookie! It's a small gesture of gratitude that means a lot to me and helps me keep creating free educational videos for you. Use the link to make a contribution: bit.ly/CodeBeauty_BuyMeACoffee
    However, please don't feel obligated to do so. I appreciate every one of you, and I will continue to share valuable content with you regardless of whether you choose to support me in this way. Thank you for being part of the Code Beauty community! ❤️😇
    Follow me on other platforms:
    Instagram 📸 - / truecodebeauty
    Twitter 🐦- / truecodebeauty
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 997

  • @CodeBeauty
    @CodeBeauty  2 ปีที่แล้ว +58

    📚 Learn how to solve problems and build projects with these Free E-Books ⬇️
    C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book
    Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook
    🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/
    Experience the power of practical learning, gain career-ready skills, and start building real applications!
    This is a step-by-step course designed to take you from beginner to expert in no time!
    💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
    Use it quickly, because it will be available for a limited time.

    • @SA-oj3bo
      @SA-oj3bo 2 ปีที่แล้ว

      Will you join me if I offer you a coffee? Did you explain somewhere in a video the purpose of #include ?

    • @AmberRathour366
      @AmberRathour366 2 ปีที่แล้ว +1

      How kind. Thanks so much.

    • @MrDmadness
      @MrDmadness 2 ปีที่แล้ว

      So basically using namespace std; == using a lot more memory, and having a less efficient program... yes ? I will totally understand you a coffee, I'm learning to code to get out of trades, I can stare at lines of code all day but 25 years in trades is taking its toll,on my body

    • @prime1marvel90
      @prime1marvel90 2 ปีที่แล้ว +1

      Thank you for this video
      Love from India 😌

    • @remasteredretropcgames3312
      @remasteredretropcgames3312 2 ปีที่แล้ว

      I get error out of the box making zero changes to the defaults and its a wild goose chase trying multiple failed proposed methods to fix it. They need to just stop changing visual studios unless they really like having even fewer programmers.

  • @l.p.1967
    @l.p.1967 3 ปีที่แล้ว +728

    In addition to what you said in the video, a common problem of "using namespace std" is if you try to create your own function and give it the same name that is already present in std namespace, that can lead to name collisions and ambiguity.

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว +174

      Pinning this comment since it is very useful info, continue reading...
      For those that need an example to understand this, use the one below:
      In the std namespace exists a function called abs(), which returns the absolute value of a number. So if you try to do
      cout

    • @PhilipAlexanderHassialis
      @PhilipAlexanderHassialis 3 ปีที่แล้ว +17

      @@CodeBeauty The sensible thing and the one most adhering to the roots of C++ (i.e. janky mainframes where the greater prophets Ritchie and Thompson first summoned The Daemons), should be to either:
      - Call the one that is lexically closest to main or simply the one declared in your program
      - Screw the above and call the one in the std library because you must respect other people's labour of putting it together
      - Screw everyone and try to call a random function whose signature matches your function's since the syntax tree produced during compilation throws a hissy fit
      - Screw the system by deciding that your function should arbitrarily be cast to a function that points at (char *)0, hence resetting your system when you call it
      - Or simply do all of the above in a not exactly random order if you are using Visual C++
      Pick your poison.

    • @OGBhyve
      @OGBhyve 3 ปีที่แล้ว +2

      @@PhilipAlexanderHassialis * DEC PDP machines like the famous PDP-7 and PDP-11 were considered minicomputers at the time.

    • @eventhisidistaken
      @eventhisidistaken 3 ปีที่แล้ว +9

      Is it really a common problem? It's really only a problem when people who have no training and no experience try to write code. You wouldn't trust a car built that way, and neither should we expect or allow production code to be built that way. If you are so ignorant that you are unfamiliar with the standard template library, you have no business writing code professionally.

    • @nishantjoshi6712
      @nishantjoshi6712 3 ปีที่แล้ว +6

      I also didn't understand this until I started competitive coding and got clashes for min and max named functions. I used 'using namespace std;' but i also made min functions like
      int min(int a, int b, int c){
      return min(a, min(b, c));
      }
      this type of function is only possible if I use min from as std::min.
      took me some time to understand

  • @ozgurbarsayhan226
    @ozgurbarsayhan226 3 ปีที่แล้ว +339

    The English you speak is really clean and understandable for even people not good at English like me.
    In this way, I practice both English and programming at the same time.

  • @tuandroidgeneral2091
    @tuandroidgeneral2091 3 ปีที่แล้ว +571

    Sorry, i don´t trust people that doesn´t use dark mode....

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว +55

      Hahaha, why not? 😆🤔😋

    • @shottyman6013
      @shottyman6013 3 ปีที่แล้ว +44

      @@CodeBeauty Your poor eyes. How can you use light mode? My eyes get burned when I use it.

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว +285

      I don't like light themes either, and I personally use dark ones, but I get messages from people who are watching my videos with a very bad internet connection, on a small resolution, and for them, it's much easier to read dark letters on the light background than vice versa.
      That is why I continue to use a light theme, even though other people commented that a dark theme is their personal preference as well. I believe that making it available for more people is a stronger argument.
      I would recommend tools like f.lux
      I use them with both light and dark themes, and they help a lot with eye strain. Or you can put on shades 😎😎😁

    • @j_respect5948
      @j_respect5948 3 ปีที่แล้ว +22

      @@CodeBeauty that's so nice of yours

    • @j_respect5948
      @j_respect5948 3 ปีที่แล้ว

      @@CodeBeauty are u a girl or a trans?

  • @zombiehellmonkeygaming1956
    @zombiehellmonkeygaming1956 3 ปีที่แล้ว +135

    I've been using 'using namespace std' without even knowing it was bad practice, thank you for the very clear explanation.

    • @ChrisCarlos64
      @ChrisCarlos64 3 ปีที่แล้ว +25

      In small projects it can be fine, something for playing and testing to just reduce some typing. However it can lead to a bad habit if you do it in larger projects, so often times it's best to keep bad habits away from smaller projects even if you're unable to remember that. I just only ever use it for the "hello world" equivalent of applications I write to test out some concepts.

    • @musashi939
      @musashi939 3 ปีที่แล้ว +8

      Much more important is to understand why it's bad practice. It's not always black and white. There are a few things that are considered bad practice in programming and when you look deeper into it, you don't find a useful answer why. It's like it was a bad practice for whatever reason in the past but the original reason is already forgotten and remains only left in the brains of already dead people.

    • @obinator9065
      @obinator9065 3 ปีที่แล้ว +2

      restrain "using namespace ..." to local scopes (and really only for absolutely unreadable things like std::chrono::high_resolution_clock). using aliases are ok too. (i.e using str = std::string) if you declare them in namespaces, (to be exact "unique scopes" that includes classes too!), such that locality precedence will be used.

    • @myenglishisbadpleasecorrec5446
      @myenglishisbadpleasecorrec5446 3 ปีที่แล้ว +2

      90% of what I learned from C ++ afterwards turned out to be wrong in some way

    • @mxbx307
      @mxbx307 2 ปีที่แล้ว

      @@obinator9065 You can also use the "auto" keyword for horrors like std::chrono::high_resolution_clock and the compiler will make a very good guess at what the type is.
      You can also define things differently.

  • @davidjohnston4240
    @davidjohnston4240 3 ปีที่แล้ว +355

    I've never used "using namespace std;" but now I know it's not recommended, I'm going to use it all the time.

    • @pradhumnarajput9722
      @pradhumnarajput9722 3 ปีที่แล้ว +12

      @@381delirius *world
      *return 0;
      }

    • @mparagames
      @mparagames 3 ปีที่แล้ว +18

      @@pradhumnarajput9722 but he wanted to output "hello worlf", not "hello world"

    • @justjuniorjaw
      @justjuniorjaw 3 ปีที่แล้ว +1

      @@pradhumnarajput9722 He copied and pasted it, not typed it.

    • @CasualCoder
      @CasualCoder 3 ปีที่แล้ว +10

      Some just want to watch the world burn...

    • @eventhisidistaken
      @eventhisidistaken 3 ปีที่แล้ว

      I recommend that. Your brain will now explode from illogicing itself.

  • @hemanthkotagiri8865
    @hemanthkotagiri8865 3 ปีที่แล้ว +98

    This is by far, the most clear and concise explaination of why "using namespace std" is considered a bad practice for specifically "large scale applications". I absolutely love the way you teach, Saldina! Teaching is an art, and you certainly have mastery over it!

    • @saturn7_dev
      @saturn7_dev ปีที่แล้ว +7

      Really...she actually never explained why at all....

  • @Rockout52
    @Rockout52 3 ปีที่แล้ว +66

    I don't remember my teachers being this nice when I was at school, I might of actually enjoyed going if they were, I'm working my way through your videos right from the start, I'm also reading a couple of C++ books, your video's are much better for explanations and understanding. My motivation for learning to code is doing something that you can get totally immersed in so you don't have to think about the isolation and loneliness of lockdown, so you are my only company and mentor, I've watched over 20 of your video's so keep them coming please.

  • @AnupamShaw
    @AnupamShaw 3 ปีที่แล้ว +16

    I never thought about the reason we use "using namespace std", but thanks to you because now I've increased my knowledge. Each day we learn something new.

  • @rakeshbaboeram1808
    @rakeshbaboeram1808 3 ปีที่แล้ว +14

    I never understood C++ in college. Thanks for explaining topics in a clear manner. I'm attending the 10hrs full course.

  • @mroldanmx
    @mroldanmx 3 ปีที่แล้ว +5

    Thanks for taking the time to explain it so eloquently!
    I hadn't programmed in C++ since college (~10 years ago) and never really thought about "namespace std", I just used it so the programs would run.

  • @andreialexander405
    @andreialexander405 ปีที่แล้ว +7

    Saldina, you are absolutely brilliant. Enormous thanks for your work here on this channel.

  • @daophilac
    @daophilac 3 ปีที่แล้ว +49

    I am already a professional programmer. So I didn't ask for anything. But TH-cam gave me a good explanation, clear English and a perfect beauty anyway.

    • @PIFFthePUFF420
      @PIFFthePUFF420 2 ปีที่แล้ว +1

      I believe you when you say you're a programmer

  • @tallysandy6354
    @tallysandy6354 3 ปีที่แล้ว +5

    You are the only person that gets me excited about programming. This is really fun. This is a very good video. Keep it up with the good work, Saldina.

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว +1

      Wow, that is the best compliment. I'd like to motivate everyone to learn programming! Thank you! 🙏💙

  • @samsonjoe180
    @samsonjoe180 3 ปีที่แล้ว +6

    thanks for the clear and concise explanation....
    You are making me love C++

  • @diliupg
    @diliupg 3 ปีที่แล้ว +2

    I knew you will do this video when I noticed you using the std namespace in your 10 hour course. Good you cleared that one . Thanks Saldina!

  •  3 ปีที่แล้ว +3

    I just found your channel and I want to thank you for this precious content. Saludos desde Colombia.

  • @NebulaM57
    @NebulaM57 3 ปีที่แล้ว +3

    This was very informative. Thank you for your simplified explanation. It also helped to explain the double colon operator as well as a better understanding of the Using command. I also really enjoy how you show the compiler output compared to the PVS-Studio checker. I think that's something many tutorials miss when teaching coding. If you can't understand the debug errors, you'll never increase your coding knowledge. Thank you again!

  • @Sp3ctroMusic
    @Sp3ctroMusic 3 ปีที่แล้ว +23

    Thank you for clearing my doubt 🙏❤

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว +2

      You’re welcome. I'm happy to help! 😊🥰

  • @Cerv_guitars
    @Cerv_guitars 3 ปีที่แล้ว

    It's nice to see videos that aren't 5 years old on the youtube. Thanks for putting in the time to help us beginners.

  • @Filatov75
    @Filatov75 3 ปีที่แล้ว +2

    The best teacher I have ever met.

  • @000adrianelpiola000
    @000adrianelpiola000 3 ปีที่แล้ว +3

    You are a good teacher, even better than my university's teachers. I can understand you better than a teacher speaking my language.
    Gettings from Argentina.

  • @evanhutchinson9206
    @evanhutchinson9206 3 ปีที่แล้ว +2

    Thank you for the crystal clear explanation. I am getting back to C++ (after a few years of using very high-level, dynamically typed languages on a daily basis). I remember hearing about how the "using namespace std" thing was not a very good practice but no clear explanation was given to me. Even in introductions classes at school, the teachers would use it but did not bother to give us some more details about this practice, as the language was not a very big part of our program anyway (it was mostly centered around Java, Python, and common database and web-related language).

  • @anon343
    @anon343 3 ปีที่แล้ว +1

    Thank you for properly taking the time to explain this, it is hard to get a straight answer to such a basic question.

  • @malgailany
    @malgailany 3 ปีที่แล้ว +3

    I really like the clarity and simplicity of your videos.
    Thanks.

  • @mayanksuthar4967
    @mayanksuthar4967 2 ปีที่แล้ว +3

    your way of explanation is amazing thanks for clearing all my doubt.

  • @frktons
    @frktons 3 ปีที่แล้ว +1

    Thanks Saldina for the clear explanation. I am not used to use C++, but it's a pleasure to listen to your lessons.

  • @martonkos5775
    @martonkos5775 3 ปีที่แล้ว +2

    Really good documentation! This is a really good way to teach others! Keep up!!!

  • @JoaoVictor-ge8bx
    @JoaoVictor-ge8bx 3 ปีที่แล้ว +6

    Holy shit, I just started to learn C++ by my own and stumbled into this exactly same question and couldn't find any clear answer. Thank you for this !

    • @manusharma9089
      @manusharma9089 3 ปีที่แล้ว

      Same thing happend with me .
      Love you ma'am.

  • @scottv6506
    @scottv6506 3 ปีที่แล้ว +3

    You are and excellent teacher. I never really understood the differences. You have completely cleared it up for me. I hope you become huge on youtube. You deserve it and your skills shine through beautifully. Thank you

  • @duepyter215
    @duepyter215 3 ปีที่แล้ว

    I forgot everything I know about cpp but every time I watch your videos I remember what I went through to learn cpp.
    Thank you.

  • @priyanshusaxena7157
    @priyanshusaxena7157 3 ปีที่แล้ว +2

    Thank you ma'am for this advice, I was using namespace std for a long time!!

  • @sieyk
    @sieyk 3 ปีที่แล้ว +62

    Been coding with C++ for awhile and never knew you could do "using namespace::function;". How wonderfully useful!

    • @igorswies5913
      @igorswies5913 3 ปีที่แล้ว +2

      if you do that then what's the point of having the function in a namespace?

    • @sieyk
      @sieyk 3 ปีที่แล้ว +3

      @@igorswies5913 because it's used mostly for functions that are already defined in a separate namespace. it's just to remove the namespace scoping for that particular method.

    • @israellewis5484
      @israellewis5484 2 ปีที่แล้ว +6

      @@sieyk And if you don't need the whole library of functions, no point in using namespace when you can define the specific functions you need. It saves memory and compile time.

  • @ManojKumar-pi7hf
    @ManojKumar-pi7hf 3 ปีที่แล้ว +4

    That was new for me. Great job gal ❤❤ Luv from India 🇮🇳

  • @tf.y
    @tf.y 2 ปีที่แล้ว

    i'm completely amazed at how clean your english is. i'm not a native english speaker and i could understand every word you said.
    As for the video, it was a great explanation. I used namespace without even knowing what it did. i just thought it was necessary because i watched it in tutorials.
    now i am not gonna use it anymore.
    Thanks for this great video! you gained a new subscriber.

  • @PROTOTYPZ
    @PROTOTYPZ ปีที่แล้ว

    Just found your channel yesterday, and so far I'm loving it. You're so clear about your explanations which makes it really easy to follow.

  • @bositkhonsidikov8528
    @bositkhonsidikov8528 3 ปีที่แล้ว +3

    Very great explanation from u, thanks so much indeed 🤗🤗🤗

  • @user-uu6tx6sw7l
    @user-uu6tx6sw7l 3 ปีที่แล้ว +3

    Hello from Russia!
    Your videos is helping me to be a good student, thanks :)

  • @danmarquez3971
    @danmarquez3971 3 ปีที่แล้ว

    You are one of the best teachers ever! Thank you, Saldina!!

  • @Sergeant_Mahdi
    @Sergeant_Mahdi ปีที่แล้ว +2

    Your contents are the best, thank you for these videos
    actually, I'm a self-learner and learned coding from a book
    most of the titles was very mystery to me but you specified them clearly that I could understand them completely at first time

  • @abdulrahmanalshameery7097
    @abdulrahmanalshameery7097 3 ปีที่แล้ว +13

    Although I am Arabian, but when I hear to you i am imagining as l hear to Arabian person, because your spelling is very very good.

  • @The.gm63
    @The.gm63 3 ปีที่แล้ว +67

    Do a c++ algorithms and data structures full course please

    • @mujtabamujeeb786
      @mujtabamujeeb786 3 ปีที่แล้ว

      I second that. Please youre really good at explaining things

    • @birdhunyar2327
      @birdhunyar2327 3 ปีที่แล้ว

      data structures aint a girl's job xd

    • @AlexisSuarezDev
      @AlexisSuarezDev 3 ปีที่แล้ว +4

      @@birdhunyar2327 why not?? they are good as well as boys. this is the most stupid comment i have read.

    • @mujtabamujeeb786
      @mujtabamujeeb786 3 ปีที่แล้ว +5

      @@birdhunyar2327 r u dumb or something? This is the most ridiculous statement I’ve ever heard. Just by your statement I can tell you’re one of those piece of shit. She knows more than you could ever know. She is smarter than you bro move on.

    • @AlexisSuarezDev
      @AlexisSuarezDev 3 ปีที่แล้ว +1

      @@birdhunyar2327 the olny little brain here is your brain. girls are powerful for those topic too.

  • @human3444
    @human3444 ปีที่แล้ว +1

    I have tried to learn C from tutorial videos for years, but I couldn't concentrate and follow through to the end, but when I first saw your video and how you expressed it clearly and without borders, relatively fast and with good example, I was excited. I was struck and turned into a basic C language subject. I understood well and easily. Thank you very much for your efforts in the advancement of science and service to humanity. I am praying for you, O God. With his permission. I wish you health and success. Also, thanks to your respected family and teachers who taught you. And I am also proud of the place where you grew up. With best regards

    • @st4ndby
      @st4ndby 8 หลายเดือนก่อน

      You overdid it Bro. No you just a creep

  • @Shuham00723
    @Shuham00723 ปีที่แล้ว +2

    Thank god finally i found c++ depth explaination course 😭😭😭 love from india mam

  • @lilo621
    @lilo621 3 ปีที่แล้ว +100

    In a nutshell: it's basically like borrowing a whole shelf instead of the three books you actually need for your homework.
    EDIT:
    AND...
    Specify from which book it comes from in order to do away with ambiguity
    Ex.: bookOnChildren::kid() vs bookOnGoats::kid()

    • @marym9003
      @marym9003 3 ปีที่แล้ว +3

      Wow, great example, love it!!

    • @abduldanish9953
      @abduldanish9953 3 ปีที่แล้ว

      Lilo start a TH-cam channel your nutshelling of concepts are awesome 😂

    • @yensteel
      @yensteel 3 ปีที่แล้ว

      Wah, so simply explained!

    • @aeros39
      @aeros39 3 ปีที่แล้ว +5

      and why not borrowing the whole shelf? what is the disadvantage? does it make your program slower?

    • @thetwogoats6851
      @thetwogoats6851 3 ปีที่แล้ว

      That was funny and really explained everything 😂

  • @grayfoxtrots
    @grayfoxtrots 3 ปีที่แล้ว +5

    Thank you for sharing.

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว +2

      My pleasure! 🤗🤗

  • @WendyMoule
    @WendyMoule 2 ปีที่แล้ว

    I taught myself to code back in 90's for my PhD so this was one of my bad habits. Your videos are very good and much appreciated!

  • @alchiissa2231
    @alchiissa2231 ปีที่แล้ว +1

    Your simplicity in explaining the code, is very apreciated, many thanks

  • @fy9090
    @fy9090 3 ปีที่แล้ว +3

    I like your teaching and it is very simple and easy to understand. Can you do some windows system programing (API)using C++ tutorials in future ? Thank you.

  • @muhammadrehan2418
    @muhammadrehan2418 3 ปีที่แล้ว +5

    Keep you the great work mam 🥰

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว +1

      Thank you, I will!🥰🥰

  • @user-bb3mb1wk9n
    @user-bb3mb1wk9n 3 ปีที่แล้ว +2

    Great video! Clear explanation and straight to the point.

  • @saumyanair8827
    @saumyanair8827 2 ปีที่แล้ว +1

    Very clear and informative.Keep it up!!!

  • @mattasatishkumar4132
    @mattasatishkumar4132 3 ปีที่แล้ว +16

    such good explanation!!
    may you get 1m subscribers god bless you keep teaching dear!!!
    love from INDIA!!!!!!!!!!!!

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว +7

      Thank you so much and God bless you to!
      Sending a lot of love for India! Will come to visit one day! 🇮🇳🧡🤍💚

    • @ankitraj4991
      @ankitraj4991 3 ปีที่แล้ว +1

      @@CodeBeauty come soon !! You are always welcome ;)

    • @mattasatishkumar4132
      @mattasatishkumar4132 3 ปีที่แล้ว +2

      @@CodeBeauty we are very much glad to see you in one day always welcome mam!!!!

  • @jackzugna5830
    @jackzugna5830 3 ปีที่แล้ว +3

    Another example for not using "using namespace std" is, for example, if you need a custom class, or struct, with the same name as the one in std's namespace.
    Example:
    using namespace std;
    struct string {
    //error
    };
    -------------------------------
    //I can write:
    using String = std::string; //if you need of this.
    struct string {
    //no error
    };

  • @SebastianSanchez65
    @SebastianSanchez65 3 ปีที่แล้ว +2

    this is the type on information i like, intrinsic programming, not just because!

  • @loool87871
    @loool87871 2 ปีที่แล้ว +1

    Really amazing, your way of explanation, explain with trials, your topics, everything is perfect. Your videos saved for me a lot of time searching through many references to find the info. I appreciate it!. Keep going on!

  • @kuttykitchen6623
    @kuttykitchen6623 2 ปีที่แล้ว +4

    Wowwwwwwww that insane.. I didn't know about this i think "using namespace std" is just a decoration. Lol me 🙂
    And thenks for these information a subscribe from me.
    Oops! 🤓 there is no emoji for subscribe.. umm its okey for now "👍".

  • @nelsondias1226
    @nelsondias1226 3 ปีที่แล้ว +6

    Very good, from Brazil. \O/

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว +6

      Obrigada! Muitos beijos e abraços para Brasil! 🇧🇷💚💛

  • @DaBaSoftware
    @DaBaSoftware 2 ปีที่แล้ว +2

    I never learned about the individual namespace declarations, great tutorial!

  • @vishwa_tennyson
    @vishwa_tennyson 2 ปีที่แล้ว +2

    thank you for making a clear video about namespaces

  • @raz0229
    @raz0229 3 ปีที่แล้ว +3

    Good to see other creators making these amazing tutorials for free. I have a channel too but not specifically oriented to programming, because often times they don't get enough views. Your videos motivate me to continue making progress. Good luck. God bless you. #RoadTo100K

  • @pierreabbat6157
    @pierreabbat6157 3 ปีที่แล้ว +8

    Another thing: DO NOT EVER use "using" in a header file! If you use "using" in a header file, there's a chance that another programmer will include your header file and define "string" or "isfinite" or whatever in his .cpp file and get the wrong one.

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว +3

      Great advice! Thanks! 🤗🤗🧡

  • @ahmedhafiz2419
    @ahmedhafiz2419 3 ปีที่แล้ว +2

    I am actually interested in namespace now. Finally seeing somebody making use of own namespace.
    Also, can you make a video on making a c++ library (or an app)

  • @sidharthanand9946
    @sidharthanand9946 2 ปีที่แล้ว +1

    Was writing using namespace std for years without knowing the reason behind it. Loved this video. Already subscribed.

  • @Nitramynot
    @Nitramynot 3 ปีที่แล้ว +3

    Hi! Second day here learning C++. The thing is, why using namespace instead of just giving a different name to a variable? Does it work as a structure in other languages with variables, functions and so on?
    Other thing about bad practices that I've been reading is system("pause"), which only works in windows, not in macOS or Linux. Can you give more examples about this and maybe some alternatives? Thanks for your work, your videos are great.

  • @coefficient1359
    @coefficient1359 3 ปีที่แล้ว +4

    Mam can you please make a video on lambda expression in c++, it looks like [&]. I can't understand from the web and you explain things really good.🤗

  • @gorangogo740
    @gorangogo740 3 ปีที่แล้ว

    Ovo je jedan od najboljih kanala na youtube sto se tice C++ jezika, sve je vrlo jednostavno i jasno objasnjeno ;)

  • @beoxsgaming9388
    @beoxsgaming9388 2 ปีที่แล้ว +1

    THANK YOU!!!!
    It makes so much more sense now!

  • @TheRealGimmle
    @TheRealGimmle 3 ปีที่แล้ว +3

    as a 15 year programmer (not C++) I love how you explain these things, although it was pretty obvious to me, I do see why people would be confused or try to use this.
    Great tutorials!

  • @shinamashiro9671
    @shinamashiro9671 3 ปีที่แล้ว +4

    Yey! I'm not first but I'm early and it's already 2 am yet I can't sleep.

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว +1

      I also tend to work late at night. Sometimes there are pop ups on my videos saying something like "You get up in 3 hrs"
      Not the healthiest, I know, but... 🤷‍♀️
      Btw, it's currently 8pm where I live ⏰
      Good night! 🤗🤗

  • @DanielGarcia-yo9sz
    @DanielGarcia-yo9sz 3 ปีที่แล้ว +2

    Even though I know how to code in C and C++, I didn't know what does that line of code do and also as u mentioned, why many coders say that this is a bad habit and I've been looking for the answer till now!
    Thank u so much for this explanation Saldina! 🙂

  • @ademhilmibozkurt7085
    @ademhilmibozkurt7085 3 ปีที่แล้ว +1

    Awesome video, awesome telling! Thank you.

  • @WinterRav3n
    @WinterRav3n 3 ปีที่แล้ว +5

    Damn, I really love how Saldina "rolls" that "R" american way!
    By the way, great explanation and tut :)

  • @ankitraj4991
    @ankitraj4991 3 ปีที่แล้ว +20

    Don't forget me ma'am, when you become a big youtuber😅😜will watch this in morning till then good ni8😃🙏🙏

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว +5

      Long way to go, but I'll give my best! Thank you for supporting me and have a good night! 😴🤗🤗

  • @gamesdogabriel
    @gamesdogabriel 3 ปีที่แล้ว

    Your explanation took a long time, but it was so crystal clear that i feel like I truly learned.
    I just noticed the first part of my comment might be seen as an complaint, but it is in fact a thank you for sharing your time.

  • @SeyavashBit
    @SeyavashBit 2 ปีที่แล้ว +1

    Thank you so much for clarifying std namespace once for all! Non of previous search results helped me understand

  • @gaetanocercielloreal
    @gaetanocercielloreal 3 ปีที่แล้ว +6

    good video

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว

      Glad you enjoyed! 🤗

  • @Dziugis
    @Dziugis 3 ปีที่แล้ว +23

    So you should probably use `using std::something_here;` on really big scale projects where you need that code would work as fast as possible and for regular use `using namespace std;` is fine

    • @user-sl6gn1ss8p
      @user-sl6gn1ss8p 3 ปีที่แล้ว +8

      There shouldn't be a difference in speed on the compiled code, as per stackoverflow.com/questions/9324844/will-folders-and-namespaces-affect-performance-in-c-and-cross-platform
      The problem, as I understand it, is more along the lines that if you always go "using namespace std" at the start of every file, you're essentially negating the namespace - namespaces are useful for organizing the names of your functions and variables, and by unleashing std you are actually limiting yourself. Since std is so big and also deals with some very common things, it's not unusual that at some point you - or a library you are using or a code from someone else you have to work with - might want to call something else by a name which already exists inside the std namespace (say, a custom string class), and then you'll have to deal with that, which can be a problem.
      Now, personally, I've never had trouble with this - I believe it's one of those things that matter a lot more for bigger code bases shared between a group of people -, but even them I like the clarity of knowing I'm using the std version of a function or class instead of some custom one.

    • @cleanpoop9929
      @cleanpoop9929 3 ปีที่แล้ว +1

      @@user-sl6gn1ss8p that makes sense. Thanks!

  • @hv6411
    @hv6411 3 ปีที่แล้ว +1

    Thank you Salina! You are a great teacher☺️

  • @debangshumallik
    @debangshumallik ปีที่แล้ว +2

    this was the best doubt-clearing session of namespace std........huge thx❤️❤️

  • @daxu9605
    @daxu9605 3 ปีที่แล้ว +3

    The reason you gave is actually a reason to use this namespace. It’s to avoid naming anything that overlaps with the std lib. By using the entire std space, you implicitly make your code much more understandable. Whoever reads the code no longer need to check what namespace something very common like cout is in.
    It’s a very bad practice to name anything that overlaps with the standard lib. If you are going to do it, it’s best to explicitly declare your namespace. This way when the project grows larger, it will be very easy to decipher.

  • @dundyd3612
    @dundyd3612 3 ปีที่แล้ว +9

    08:16 - that was funny 😂😂

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว +5

      Hahaha, that was a mistake 🤷‍♀️😅😅

    • @TurntableTV
      @TurntableTV 3 ปีที่แล้ว +2

      She forgot to put the using statement for english.😂

    • @moitest3628
      @moitest3628 3 ปีที่แล้ว

      😂😂

  • @ivanetinajero
    @ivanetinajero 2 ปีที่แล้ว +2

    Wow. This is great explanation. You convert difficult concepts in plain english words that are very easy to understand. Best explanation of namespaces on the internet. Regards from Mexico.

    • @CodeBeauty
      @CodeBeauty  2 ปีที่แล้ว +1

      🇲🇽❤️💚

  • @Chickengbs
    @Chickengbs 2 ปีที่แล้ว

    Thank you for this CodeBeauty, this really helpted me understand!

  • @garbanzo1997
    @garbanzo1997 2 ปีที่แล้ว +11

    std::cout

  • @requiem418
    @requiem418 3 ปีที่แล้ว +4

    12:24, for people who already know what namespaces are and want to cut straight to the chase, and tbh the reason is obvious and implicit.

  • @arkasingha6111
    @arkasingha6111 3 ปีที่แล้ว

    Thank you so much, you did a good jab... Keep up the good work...

  • @jronbroke
    @jronbroke 6 หลายเดือนก่อน

    i never saw this type of explicit explanation .i greatly appreciate it.

  • @sil1235
    @sil1235 3 ปีที่แล้ว +3

    It should be also noted that "using namespace ..." is especially problematic in header files, because it declares it for all users who include that file by default (and will apply to everything they use after that include in given file!). So if you ever decide to go with using namespace std or similar for whatever reason, make sure it is limited to implementation (cpp) files only... (the same problem is true actually also for the "using std::cout;" etc)

  • @mikoajzabinski3569
    @mikoajzabinski3569 3 ปีที่แล้ว +3

    Say what?
    First of all, the namespace is not include. So "using namespace ..." do not include anything to your code. Remove iostream from the top and You will see.
    The problem with namespaces is something very different than what you mention.
    In your case, if you type after definitions of your namespaces:
    "using namespace namespace1;
    using namespace namespace2; "
    Your code will not break until you will use one of the members that share names in both namespaces. In one file program that may not be a problem, a bigger project with libraries and multiple files may have such issues. Furthermore, you creating ambiguity that may provide an additional challenge for someone debugging your code.
    Using is just a powerful tool to be used with a lot of caution. Adding spaces is a way to organize part of a bigger codebase. And using is not prohibited, use it sparingly, and never put it into header files :)

  • @haseensiddiqui2087
    @haseensiddiqui2087 2 ปีที่แล้ว +1

    Thank you so much for this answer. I am a beginner to C++ and I had a lot of confusion. Thank you for clearing up my confusion!

  • @rokomedancic349
    @rokomedancic349 ปีที่แล้ว

    Puno ti hvala. Puno sam naucio. I posebno su mi zanimljivi tips&tricks. Koje kod drugih nisam nikad vidio ovako detaljno objasnjeno. Svaka cast. Najbolja si do sada s obzirom na videa koje sam gledao o cpp-u.

  • @natnatxti
    @natnatxti 3 ปีที่แล้ว +5

    The 33 dislikes are from David's and David's mom.

  • @josepablolunasanchez1283
    @josepablolunasanchez1283 3 ปีที่แล้ว +3

    1980: Only geniuses can be programmers
    2021: Saldina teaches normal people how to be a genius

  • @user-qy8cb8iw9l
    @user-qy8cb8iw9l 2 ปีที่แล้ว

    Very well done. Clear understandable English. Clear structure in explaining. This helps beginners and hobbyists a lot. Thank you very much.

  • @SonN-PAml
    @SonN-PAml ปีที่แล้ว

    Saldina, the way your teaching is wonderful. I love it.

  • @jesusadolfodiazcenteno5272
    @jesusadolfodiazcenteno5272 3 ปีที่แล้ว +4

    "Hey you already define a variable called age once, and now you are trying to define another variable with the same name, why are you doing that?"
    "Well maybe because I'm an idiot"

  • @DJSaez-ll8or
    @DJSaez-ll8or 2 ปีที่แล้ว +1

    You're amazing. Thanks so much!

  • @amansharma2957
    @amansharma2957 3 ปีที่แล้ว +1

    Thank You Saldina! It was really helpful.

  • @bstrouble
    @bstrouble ปีที่แล้ว +1

    Thank you! Im reviewing C++ as I am becoming a programing tutour at my local college