The best C++ series that I saw. This is not a "do this, do that" manual, You shows really knowledge about You talk. Thank You!
@mytech67797 жыл бұрын
Toyota acceleration issue that caused several deaths, was found they had just been hacking together hamfisted extensions to their program for years and had something over a 1000 global variables. They ended up loosing their case not because of a proven bug but because the code was so bad it couldn't be properly sorted and debugged by a team of experts over 2 years.(NASA spent the first 9 months, then private firms picked it up for another year and a half.)
@HermanWillems6 жыл бұрын
I wouldn't expect that from such a company with such high quality standards. Seems their quality standards only applied to hardware. Software is pretty new thing in the car industry. And seems that it was just a secundairy thing.. a black box where officials know nothing about. But hey... it can be worse. It could also be like VW who did actually put software on purpose to mislead our society. Also C & C++ is efficient. But its pretty dangerous languages for such kind of software. C++ has become better and better, there are some "ways" to program these kind of stuff. But C++ allows humans to make safety errors. Cars will have more and more software... it's scary to think that it's programmed by languages who have no build in safety / restrictions.
@vertigo69826 жыл бұрын
NASA must've lost the technology for debugging when they lost the technology to get back to the Moon.
@Stelios.Posantzis5 жыл бұрын
Bad programmers should be held accountable for the consequences of the intended use of their code -.just like every professional is accountable for the product of their work.
@DigitalDivotGolf5 жыл бұрын
@@vertigo6982 Why spend hundreds of millions to go back to an inhabitable planet? Mars is a better choice to explore.
@GamblerBE5 жыл бұрын
@@DigitalDivotGolf Because Mars is not inhabitable??
@RemotHuman Жыл бұрын
There's actually three meanings of the static keyword in C++ (that I know of) (the third unmentioned one is discussed in cherno's video "Local Static"): 1. Local Static: static var inside of a function: value sticks around throughout program lifetime so same value sticks around if you rerun the function (only gets initialized once) 2. Static globally scoped var / func: Makes it visible only in this file, normally globals would be visible everywhere in program when linked 3. Static Class Vars or Functions: belongs to root class, not instances of it, same values shared across all instances (so cant access instance variables/'this' from static methods)
@stephenyork73185 ай бұрын
A static variable outside of a class but in a standard function also holds its value after the stack is cleaned up. Next call to the function the variable initially has its previous value.
@sleepyNovember_project5 ай бұрын
He also talked about this in some video, but the information is useful anyway P.S. in the video with the title "Local Static in C++"
@OmerFarukGonen Жыл бұрын
One thing should have been stated that we do not #incude the Static.cpp file in our Main.cpp BUT we are compiling the files together. Since Cherno always uses the VS IDE to show examples, the IDE always compile main.cpp and Static.cpp together this means that Linker works with main.obj and Static.obj files. That's why using extern keyword with s_variable links the s_variable in Static.cpp file. This is what refering to s_variable means as stated in the video.
@kulbhushansingh11017 ай бұрын
Thank you
@drkerberos4 жыл бұрын
When people say that this or that channel is the most underrated I usually ignore them because it isn't true most of the time. After watching some of the videos I can really say that 327 thousand subscribers isn't enough for you. This channel haves covered c++ better than any other tutorial I have ever watched. You have explained and showed me stuff that I never really knew even though I call myself a programmer. I'm so glad that someone recommend your channel to me because it has changed the way I think about programming and actually executing a small or big project.
@SeamusTW3 жыл бұрын
So you're saying that this channel is underrated, because you said "327k subs isnt enough for you". Im confused. But this channel is underrated tho ngl.
@banebean21313 жыл бұрын
@@SeamusTW how doesn't it not make sense. The channel is underrated because 327k is too insufficient of an amount. Point with an explanation. where is the confusion
@gow94762 жыл бұрын
@@banebean2131 "When people say that this or that channel is the most underrated I usually ignore them because it isn't true most of the time"
@dildarsk2467 жыл бұрын
The way this series is presented is superb.
@battosaijenkins9465 жыл бұрын
@TheChernoProject, I don't understand why even use static in a class when you can already use private?
@jameshall51715 жыл бұрын
@@battosaijenkins946 'private' for classes is just used to make member variables /functions inaccessible directly from outside the class. 'static' on the other hand is used to make member variables/functions independent of an object. Meaning that they will hold the same data/ do the same thing regardless of any instances of that class. Private member variables/functions in contast do depend on the class' instances - their data/behavior change depending on the object it belongs to. Think of a static variable/function as a constant and a private one as an object's "secret". Maybe that will help.
@moviesynopsis001 Жыл бұрын
Hes a bit egotistical imho
@JamesStocks5 жыл бұрын
This video series is awesome. This is the level I've always wanted C++ explained at.
@eddyecko945 жыл бұрын
Best C++ tutorials on KZbin 👌🏿
@epsilon27254 жыл бұрын
@@abaundwal buddy. Keep your thoughts to yourself.
@objectoriented30493 жыл бұрын
@@epsilon2725 what did he say
@inosuke81272 жыл бұрын
I have been following him when he started this series Still I come back and forth to clarify some doubt. One of the best C++ series
@unrealdevop2 жыл бұрын
This is by far the best way to learn a programming language for those already familiar with how things basically work in my opinion...learn how it all functions and what everything means and then start actually putting it into practice. This gives you a broad perspective on how the system operates and allows you to make better judgement calls on when you need to do things a specific way.
@shadowrl76379 ай бұрын
Yes these are nice coming from java. Although the static part threw me off since in java we declare them using private public etc and static allows us to reference between multiple classes.
@unrealdevop9 ай бұрын
@@shadowrl7637 Yeah I assumed static just meant that you weren't going to change it so when I seen it used with a function for the first time it confused me. That's what const means though.
@serkanozturk42172 жыл бұрын
Personal notes: -static keyword has two meanings depending on what the context is: whether you use it outside of class or inside class -static outside of a class means the linkage of that symbol you declared to be static is going to be internal, i.e, it is only going to be visible to that translational unit that you defined it in -static inside class means that that variable is actually going to share memory with all of the instances of that class -extern keyword is used to accessing a variable defined in another file
@youssofprogrammer75462 жыл бұрын
very very thanks you helped me a lot with this simple comment keep it up
@null-0x19 күн бұрын
The `static` keyword actually has three meanings, the one that did not get mentioned in this video is when the `static` is present outside a `class` but inside a generic `function` before a variable. This makes the variable persistent in the stack even after the function that initialized it had gone out of scope. Note that the keyword does not make the variable global.
@venkateswarans10125 жыл бұрын
There is a meaning for static keyword inside functions. It will persists the value of local variable despite of calls.
@piechulla19664 жыл бұрын
And as long as reentrancy is not a concern, this is very nice. But in multithreaded environments...
@samarthm2414 ай бұрын
Watching this channel is so nostalgic.... I remember binging your videos in COVID and I'm glad to see the channel has grown so much!
@shahadalrawi67449 ай бұрын
So clear explanation. Thank you so much!
@ericjovenitti67472 жыл бұрын
Dog, i dont even know how much to thank you.For whenever reasons you wording just clicks with me and i'm so thankful you for doing these videos.
@JDStone207 жыл бұрын
Nice video! You have some of the best explanations of how everything works I have come across.
@bhogeswarasaikumar6351 Жыл бұрын
Mind-blowing. Excellent concept sharing
@MsJavaWolf6 жыл бұрын
Static is a very unfortunate keyword, there should have been different keywords for different concepts.
@jameshall51715 жыл бұрын
@Peterolen Wouldn't it be nice if there was a way that when a new update for a language comes out, there could also be a way to automatically update old code to be compatible with the new version? Honestly it sounds like it wouldn't be that hard. Just write a program that takes in a version of a language and translate code to conform to that version. Effectively it's a translator but for programming languages.
@general90644 жыл бұрын
Just #define it then
@callowaysutton3 жыл бұрын
@@jameshall5171 some C/C++ compilers already do this by specifying what standard to use at compile time
@adammoore38997 жыл бұрын
You are a really good teacher, man!
@ryankimbrell47604 жыл бұрын
Wow I was grasping at this concept for a while and this explained it so clearly. Thank you for these videos!
@w3w3w35 жыл бұрын
Thanks for another great video! This series is the BOMB.
@lettry52972 жыл бұрын
One of the best C++ series. Your every video is worth of watching.
@southparkclips2213 жыл бұрын
Difference of this: Sub.cpp main.cpp Int stat(){ extern int stat(); std::cout
@rebeccabroos66003 жыл бұрын
A codemonkey knows tricks, a developer knows code. Thank you for teaching us to be a developer! 🙌
@vectoralphaSec2 жыл бұрын
codemonkeys still get paid the big bucks though lol so it doesnt matter.
@denishnatiuk9212 жыл бұрын
Brilliant. So easy to get a deep and intuitive understanding from your tutorials.
@andrewfurey213 жыл бұрын
ive seen people put static variables in functions, but their not global so whats the point?
@sleepyNovember_project8 ай бұрын
Блин, всё настолько понятно и без непонятных слов, что я понял буквально всё, даже субтитры мог бы написать. Нереально информативное видео, спасибо Ян!
@jwenaposse3053 ай бұрын
Cherno, it would really be amazing if you would do a video about so called "free floating functions" and how/why they would be used and how they differ with regards to using a dedicated Utilities class with static methods... Thank you!
@hpharmit6 жыл бұрын
Your representation i of program is simple and very much easy to understand. Thanks for making such videos. Big thumps up.
@pedramhashemi5019 Жыл бұрын
During watching this series, I've learned a lot about C++ and also a lot about Cherno's house :)) great content btw!
@isaiahvita64182 жыл бұрын
great video as usual, but wheres the background music? in previous videos, you had background music that made the video so much better
@ahmedanwar9765 жыл бұрын
Best c++ tutorial ever.
@alexsindledecker36657 жыл бұрын
So basically you are just making a variable private to the file that is was assigned in. Right?
@feraudyh7 жыл бұрын
yes, for one of the usages.
@ushousewatch2 жыл бұрын
The best C++ series
@Plasticcaz7 жыл бұрын
You didn't mention static variables inside functions... void some_func() { static int a = 0; a++; }
@KayVerbruggen7 жыл бұрын
Plasticcaz For people who are wondering what it does, normally a variable gets deleted from the memory after it's out of scope, so the block of code ended. But this way it'll stay in memory. Correct me if I'm wrong, I'm pretty new to this stuff
@Plasticcaz7 жыл бұрын
That's pretty much it. In my snippet, each time some_func() is called, 'a' will be incremented by 1. So after the 3rd call, 'a' will be equal to 3.
@agfd56596 жыл бұрын
A singleton pattern may be implemented that way. Or I have seen a ECS using this feature: template unsigned int createComponentId() { static unsigned int id = 0; return id++; } template unsigned int getComponentId() { static unsigned int myId = createComponentId(); return myId; } This code will result in every class having its unique unsigned int id.
@Gilpow6 жыл бұрын
He talks about that two videos later... gg The video is titled "Local Static in C++"
@GrandNebSmada5 жыл бұрын
@@Plasticcaz Wouldn't is still be 1 because you are recreating the variable and assigning 0 to it even though it was already created?
@yiminghuang47983 жыл бұрын
You are the one who makes me consist on C++ career.
@johncappelletti33324 жыл бұрын
AWESOME Presentation! Sooooo, static in a class means its public, shared, and the same (for that class) and static outside a class means its private (for that file) fantastic, I don't feel so dumb after realizing how dumb this is. Thank you sir.
@soufianebannouni91932 жыл бұрын
Why is the linker linking Static.cpp to main.cpp without #include ?
@Zippythrone4 жыл бұрын
I just watched the header file video but I’m still a little confused on this one. Why would you need to use the extern keyword to tell the linker to look for the variable? I remember that in the header file video, you only need to include the A.h file (in other words only need to include the declaration of the variable with its definition residing in A.cpp ) to use the variable in B.cpp. The compiler will look for the variable when it tries to link all the .o files. Does the extern keyword make any difference? I would appreciate any answer!!! This is bugging me out.
@Sub-zero11234 жыл бұрын
Thanks man, great explanation. Subscribed
@asdsd-wu4yw Жыл бұрын
only one thing about this channel how pro or beginner u may be, u will get something from this videos
@Dead20982 жыл бұрын
One thing that bugs me since Linker video is: why linker tries to use variable from other file (static.cpp in this videos) if it wasn’t asked to do it? Or was it?
@null-0x19 күн бұрын
Vsauce music intensifies...
@sanjayreddy32953 жыл бұрын
You cover everything needed, awesome :)
@asafsela762 жыл бұрын
Great series!
@GenericPhantom1 Жыл бұрын
Static means that a function in file is only going to be visible in said file.
@ashwin3725 жыл бұрын
my question :, how do you get that error even if you have not added or #include static. cpp in main. cpp
@marflage5 жыл бұрын
I was thinking the sane. Hopefully, he explains that in later videos, otherwise I'll have to do some research.
@valerys41885 жыл бұрын
@@marflage you don't include .cpp files, you only include .h files. the .cpp files are listed in the MAKE file.
@marflage5 жыл бұрын
@@valerys4188 I see. Thank you
@lingyaozhang15635 жыл бұрын
@@valerys4188 where is the .h file included in the tutorial code and how does the MAKE file work?
@valerys41885 жыл бұрын
@@lingyaozhang1563 the MAKE file is the file with all the dependencies, for example if you have a.cpp b.cpp c.h and the b.cpp depends on the c.h and on a.cpp, when you recompile your code when only making changes in b.cpp you don't wan't to recompile your entire code so you recompile only b.cpp to b.o (.o = object) and relink the .o files into executable file. i don't know how you can access it in visual studio but in Clion it's one of the tabs on the left and I almost sure that visual studio does that for you automatically. the .h files included in the .cpp files you need them in, if you have a template in a.h for example and you need it in a.cpp but not in b.cpp you include it only in a.cpp . you can watch his video on header files (.h file) to understand the use of them better if you want to. sorry if the english isn't perfect it's not my 1st language.
@ashrief20478 ай бұрын
Magnificent explanation
@CWunderA3 жыл бұрын
I've always wondered why concepts like static aren't the default. If it's usually best to make things static, why don't we have static as default and a global keyword instead?
@computerprogrammer79423 жыл бұрын
It’s better to use static since most programming languages use them like that and there is much more things that you can do with static than global so it’s just better to use static
@yogeshdeveloper53464 жыл бұрын
static in global scope means you have prevented it from "exporting" to other cpp files. Right?
@kushnayak16194 жыл бұрын
ok yogesh developer
@kushnayak16194 жыл бұрын
Artem Katerynych what yogesh developer said was absolutely correct and I wanted to affirm that fact for him
@milo200602 жыл бұрын
Hmm. After watching couple times I got it now. Thanks!
@rajmishra67695 жыл бұрын
Thanks , learned a lot from such a small video.
@iisthphir Жыл бұрын
Interesting static makes a 'global' variable 'private' to tu but a member variable shared by class and it's instances. Though the usage in a function makes the most sense for the name.
@Byynx Жыл бұрын
I always come back to this video to understand other's videos about the static keyword.
@iamjovani7 жыл бұрын
Thanks Cherno!
@Koettnylle2 жыл бұрын
I thought the prime property of the static keyword was the scope lifetime aspect. At least that's how I use it the most. Great clip, regardless!
@hqDacky4 жыл бұрын
Спасибо большое очень понятно / Thank you now i know what it means
@Cynokine7 жыл бұрын
Music is broken after 20 seconds, is that intended ?
@gouravbhardwaj423 Жыл бұрын
I do not get this error, does it mean the compiler I am using resolves that?
@dmytroboiko1 Жыл бұрын
You don't have to increase the playback speed, Yan (The Cherno) already at x1.25 speed ))
@mindblower113 Жыл бұрын
I was having issues with lineker errors but I watched this video so randomly and I really saw the what's cause the error. Wow man, woo man
@pwlegolas34 жыл бұрын
Fantastic Tutorial as always....
@Xx_McJasper_xX3 жыл бұрын
Short, simple, sweet. See you in the next one.
@HobokerDev7 жыл бұрын
I have a question. Is it bad to use functions like malloc printf free etc. in c++ program instead of their c++ counterparts?
@TheCherno7 жыл бұрын
No. A lot of the C++ functions actually call their C counterparts (eg. new calls malloc), and in a lot of cases the C functions are much faster (eg. printf vs std::cout).
@HobokerDev7 жыл бұрын
Thanks.
@thepdg51607 жыл бұрын
Well, just to clarify, because I just read this, there is a trick. If you use std::ios::sync_with_stdio(false); before any cout / cin calls, cout is actually even faster than printf. However, use this only, if you're not going to use any C IO.
@SArthur2217 жыл бұрын
malloc and free don't call the constructor and destructor of the class.
@Hopsonn7 жыл бұрын
Really, it depends. Using C functions like printf is fine in C++, but using malloc/ free is really not good practice in C++
@malarius73904 жыл бұрын
Do you use/ see the use of nameless namespaces instead of static?
@brockolious2 жыл бұрын
The road to 500K! LET'S GOOOOO!!!!
@mona97413 жыл бұрын
These videos are awesome!!!
@Stelios.Posantzis5 жыл бұрын
The current number of views (49300) doesn't do you justice but judging by the rate it's growing (~100 in the last half hour) it should hopefully get really high soon.
@0xbitbybit Жыл бұрын
Haha sitting just out of focus was giving me an eye twitch, amazing series though!
@federicobau8651Ай бұрын
Do use static also improve performance? At least at theoretically level (it may improve but so little that is unrelevant)
@limmeh78814 жыл бұрын
This is an old tutorial, but FYI you haven't linked this to the static in a class/struct video :P
@SOGTULAKlamares4 жыл бұрын
Maybe because the video was defined as static and this the linker didn't see it!
@rishimenon56324 жыл бұрын
So around 2:10 main.cpp can only see the s_Variable defined in the main.cpp because the one in static.cpp is defined as static. But during the compilation of static.cpp, wouldn't it see both variables (one in static.cpp and one in main.cpp as main.cpp wasn't declared to be static). So how is the program running successfully?
@luizfelipels73 жыл бұрын
Good catch; that also happens later in the video with the function example. My guess is that the static variable/function has some sort of precedence and its global counterpart would be shadowed (ignored) when linking. But I'm just guessing, really; would be nice to know for sure.
@mmx5555 жыл бұрын
thank you, please go on like this .
@Gaelrenaultdu063 жыл бұрын
I just noticed (might be due to new version of VS2019), that even if a variable is set to static in a different cpp file, and this cpp file is not included in the source file, if this variable is reach with "extern" in the source, the variable is found and modifiable anyway. Any ideas why ?
@jerfersonmatos284 жыл бұрын
Ok, you set the function in the non-main file to be static, but the function on the main file is not static, wouldn't this one get in conflict with the static one inside the non-main file?
@luizfelipels73 жыл бұрын
OP referred to possible conflict in the non-main file, that would have 2 ambiguous functions (its own static and the global one from main file). I have the same doubt.
@Zerefse Жыл бұрын
Thanks❤
@wizardOfRobots3 жыл бұрын
Please clarify why static variables inside a function are initialised only once.
@TheDuckPox6 жыл бұрын
the problem is only on the compiler right? or is it actually problematic as a compiled program?
@NotMarkKnopfler3 жыл бұрын
So, is static, when used within a regular source file (i.e. not a class or struct) just 'kind of' the opposite of extern?
@chimpionboy6 жыл бұрын
Wow. This is so powerful.
@raf.nogueira7 жыл бұрын
Cherno is safe to use static or extern for variables like Width , Height or objects like some kind of "main" Rendering class ? And use this variables in every parts of the software , and them not using this variables passed throw parameters of references ? Sorry about my English , I am from Brazil.
@deleted_handle2 жыл бұрын
C++ has so many word i cant remember all 😵💫
@Yorgarazgreece7 жыл бұрын
The name for the first job is very confusing. why aren't they have a different keyword such as "local"?
@lxzhang49114 жыл бұрын
What is the relationship between Main.cpp and Static.cpp?? Are they just in the same project and will be automatically compiled??
@davidcfrogley Жыл бұрын
Thoughts on making "global" variables/functions static vs. placing them in an anonymous namespace?
@AjeR987 жыл бұрын
Whats the outro song name? Also keep the good work Bro!
@physicsguybrian5 жыл бұрын
Examples of why you would use this over any other approach would be helpful.
@reverseila43634 жыл бұрын
Nice!!! Thanks man.
@spacetime_wanderer5 жыл бұрын
At 3:10 you mentioned the linker will not see in the global scope, and you said 'try compile my code' and got linking error, you mean you actually built it and not only compile?
@antoinedevldn5 жыл бұрын
A++ content as per!
@debojyotichakraborty5 жыл бұрын
Along with this tutorial if we get written pdf it will be helpful. What you think?
@CWunderA3 жыл бұрын
I'm curious, what happens if you have a global variable and a static variable that have the same name? For example, in your initial example, what would happen if you changed the value s_variable in the main function (since it's both defined globally and within the translation unit)
@habib_khan2 жыл бұрын
is static preffered or an unnamed namespace?
@karthikeyanbalasubramanian73053 жыл бұрын
@02:26: How come without introducing the Static.cpp file as a header in the main.cpp able to link during you compilation ?! What am i missing ?
@АндрейБорисов-и4о3 жыл бұрын
Nice video! Thanks!
@haykav6 жыл бұрын
What's up with the camera? It's not focused, the image is blurry.
@krish3d3853 жыл бұрын
Thank you.
@Idan-tc5rt6 жыл бұрын
How does your file even know that there's another cpp file with a function with the same name if you didn't include the other file ?
@h2o11h2o4 жыл бұрын
Should also talk about local static variables
@trustedsecurity6039 Жыл бұрын
I didnt saw the videos on static keyword inside the class that he talked about at th begining of this one, it is on the "how to write a class" or the other one?