Functions in C++

  Рет қаралды 518,327

The Cherno

The Cherno

Күн бұрын

Пікірлер: 348
@cern1999sb
@cern1999sb 4 жыл бұрын
As a second year Computer Science undergrad with plenty of experience coding in other languages, I usually find code tutorials extremely dull, but you point out a lot of the intricacies of C++ and explain things concisely, so these videos have actually been very interesting so far. Thanks very much for making this series!
@krishnadevsinghchundawat5136
@krishnadevsinghchundawat5136 2 жыл бұрын
same, those 4 hour long videos just become shifting to new syntax
@sohankaushik7
@sohankaushik7 Ай бұрын
What do you guys study in CS, I'm in high school rn?
@themodernshoe2466
@themodernshoe2466 7 жыл бұрын
This is full-time youtuber tutorial quality. Thanks so much for this series and sticking with it
@MrIneedalifenow
@MrIneedalifenow 4 жыл бұрын
I'm from the future and he is a full time youtuber now, you were right
@Shishio
@Shishio 2 жыл бұрын
I am also from the future and I can confirm he is still to this day a full time KZbinr
@RaphaelGo
@RaphaelGo Жыл бұрын
I'm also from the future, he's still going for the grind
@abhijeetsingh9213
@abhijeetsingh9213 4 ай бұрын
I am also from the future and he’s still going strong.
@pixelwrinkly1528
@pixelwrinkly1528 3 жыл бұрын
i'm fast approaching my 64th birthday it's like having my grandson teach me c++ wonderful stuff many thanks for sharing your knowledge
@bigchillhousenetwork
@bigchillhousenetwork 4 жыл бұрын
This is the only KZbinr that actually breaks these concepts down. 10/10 best series
@crysist13
@crysist13 7 жыл бұрын
I'm a CS student and so far everything we do is in Java. I've always wanted to get into c++ and then wham! Cherno comes in clutch. Thx for doing this
@ashishkalam9337
@ashishkalam9337 3 жыл бұрын
C++ isn't all that fun, it's necessary for some companies and platforms and is otherwise inconvenient. Java is the way to go honestly.
@Daniel-be1xn
@Daniel-be1xn 3 жыл бұрын
@@ashishkalam9337 i think he already graduated bro
@GamestarsBulgaria
@GamestarsBulgaria 3 жыл бұрын
And? How's it going now? Did you learn c++, did you find a job?
@bluesillybeard
@bluesillybeard 3 жыл бұрын
same! I do like how convenient Java is though, so whenever performance isn't a requirement I'll probably just use Java...
@goated-yt2370
@goated-yt2370 3 жыл бұрын
@@ashishkalam9337 it all depends, it may not be fun to you but for someone else it is
@voze1905
@voze1905 7 жыл бұрын
And again, the quality of this video is truly stunning.
@weendylry5598
@weendylry5598 4 жыл бұрын
I like how fast you talk. I consume the words by a huge block of many sentences instead of one word by one word. Thanks to this, you managed to shrink 2 hours of lecture on Functions in C++ in less than 10 minutes. You are God sent
@MiningMadness0029
@MiningMadness0029 7 жыл бұрын
What?! A midway video? Am I dreaming? Has Cherno gone crazy?!
@resantic2256
@resantic2256 7 жыл бұрын
Cournaut Midweek*
@needlessoptions
@needlessoptions 7 жыл бұрын
Resantic Hey Geoff, when you gonna make the drop?
@merijnvinea3546
@merijnvinea3546 7 жыл бұрын
Cournaut idk but for sure: im going crazy 2 vids in the week!!!!!!
@resantic2256
@resantic2256 7 жыл бұрын
anthony-y what
@needlessoptions
@needlessoptions 7 жыл бұрын
Resantic Don't do this to me man. We can't discuss the details here. The er... drop. When you dropping that stuff off that I asked for?
@samdavepollard
@samdavepollard Жыл бұрын
for me the secret sauce in these wonderful videos is The Cherno's obvious passion for the subject it comes through loud and clear every time lots of youtubers grind out the vids for the likes and subscribes but this guy not only knows his subject he actually loves it, too
@IcanFlame777
@IcanFlame777 7 жыл бұрын
I haven't even started learning C++ yet, but I'm really enjoying watching these videos. They're still very useful information even for other languages.
@Plasticcaz
@Plasticcaz 7 жыл бұрын
I think it's important to understand concepts that C and C++ teach you even if you only program in higher level languages. It's good to know what the higher-level languages are doing for you behind the scenes, so you have an idea of what everything is costing you (in terms of performance, etc). That way you understand the tradeoffs you are making.
@Vazzible_gaming
@Vazzible_gaming Жыл бұрын
God, I feel like I finally understand a tutorial, I never understand tutorials I don't know why I even try to start those 9-hour 22-hour 30-hour masters courses on programming. This is digestible, this is the most comprehensive c++ tutorial I've ever watched because I actually took home some information.
@TheOnlySilverUnicorn
@TheOnlySilverUnicorn 5 жыл бұрын
Oh my God! Thank you, dude! You rock! I was struggling with even the most basic functions. I'm so brand spanking new to C++, I didn't even know how to label what I was struggling with or ask the right questions to get help from my instructor or my peers or my tutor or anyone. But you made it crystal clear! I wrote a tiny program from scratch just to practice what you taught, and it ran and behaved as I intended, thanks to you! Aaaaand... it turns out that was the only place where I was stuck (so far) so I was able to get the program assigned to me up and running as intended, too. Thank you!
@krishshah3974
@krishshah3974 4 жыл бұрын
ikr Cherno explains stuff so well :D
@informativecontent4778
@informativecontent4778 6 жыл бұрын
5:10 hope this source code helps if you've had any problem understanding #include using namespace std; void mullog(); int mul(int x,int y){ return x*y; } int log(int a,int b){ cout
@gamesbynull6528
@gamesbynull6528 7 жыл бұрын
I love the direction this c++ tutorial is going! You were a huge inspiration for me to start programming java games on my channel, and I am excited to see where this new series goes!
@Special4ce293
@Special4ce293 2 жыл бұрын
several years ago when I picked up programming due to school, not a focal point for my apprenticeship at the time... I never fully understood functions. With this video, I think i grasped the concept a lot better. TY :)
@123arskas
@123arskas 4 жыл бұрын
@Cherno i love your videos. At first when i started watching them without going for the beginning ones.....It looked tough to me. But now looking back at the beginning videos it all makes sense. YOU'RE AMAZING !!! 😍🥰
@팍준하
@팍준하 4 жыл бұрын
Ok first of all, I really did paused the video and went to instagram to actually follow you. That edit to pause the background music when you said that really brought my attention btw lol. Now onto Summary Functions are blocks of code that perform a specific task. We can remember a function by its input and output. To define a function, we have to declare whether it has a return value. If it doesnt, declare using 'void', and if it does, declare using the appropriate data type according to the result. We also have to declare the data type of inputs. There are a whole lot of benefits when it comes to using functions in an appropriate manner. 1. IT lets the code DRY, and easy to read and understand 2. It is easy to update and maintain if there are any problem that occurs. However, we shouldn't be overusing functions, since, above the appropriate level, our code could be messy and difficult to read. Deciding what is actually worth putting in functions would require us to have some decent experience with programming, but as a rough rule of thumb, just make a function whenever you find there are some lines of code that are being repeated over and over again. Going into the details of why is like this. If a function is being used not in-line(as Cherno stresses), it would result as in the compiler or CPU(what ever) jumping to the location of our binary code where the function is defined, to look for the definition, and jumping back to the place where function was executed. Calling a function also results in creating a whole stack framework with parameters and return address. This is also a waste of memory and time.(if I understood correctly.)
@belHlopez
@belHlopez Жыл бұрын
I just want to say thank you for all that you have already done for us and keep doing. The Chearno, for me you are the best tutor ever. And again, thank you!
@not2day646
@not2day646 5 жыл бұрын
you sir have earned yourself a sub. The quality of these tutorials is truly amazing. You describe things in exactly the style I like.
@Mona.Arekanti
@Mona.Arekanti 7 ай бұрын
how r u doinn
@zhuyida4917
@zhuyida4917 2 жыл бұрын
It is the best C++ tutorial in all tutorials i have learned! Love you, the Cherno!
@MarcusTL12
@MarcusTL12 7 жыл бұрын
The only problem with this series is that the videos dont come that often, so this was a pleasent supprise :D
@w3w3w3
@w3w3w3 5 жыл бұрын
Great series Cherno! really lovely.
@timholden1371
@timholden1371 4 жыл бұрын
Thank you for these videos man. I can't explain with words alone how much these videos have helped me to refine my C++ skill set.
@thinkalvb
@thinkalvb 6 жыл бұрын
I think that modern compilers won't really care if a function is inline or not, they rather use algorithms to make assumptions to decide whether to make them inline or not. Correct me if I am wrong, please do continue this... I will surely contribute as soon as I get a job - you are making my days great with c++. Learned a lot from you; really really inspirational and knowledgeable.
@aryansharma4340
@aryansharma4340 Жыл бұрын
bro inline makes the code readable nothing more in that
@zoriiginalx7544
@zoriiginalx7544 Жыл бұрын
​@@aryansharma4340what?!
@MichaelSilva-oi2sy
@MichaelSilva-oi2sy 5 жыл бұрын
U're amazing and your videos are getting even better. Congrats.
@meh1672
@meh1672 7 жыл бұрын
This is the best programming series ever! :D
@elaine6820
@elaine6820 4 жыл бұрын
This is best C++ course I’ve found on KZbin.
@SirLightfire
@SirLightfire 4 жыл бұрын
7:08, Another, more subtle, benefit to using functions is to visually, and semantically, separate logic into discrete chunks. This makes it muuuch easier to quickly parse out what a function is doing, if the individual parts of the parent functions are themselves functions. It also forces the programmer to indicate (via function signatures) which code uses which variables. This makes for more maintainable code, since it becomes much clearer where a variable is used, and what changing it will impact. General rule of thumb, is to keep functions no longer than one screen tall. Of course, it's a hard rule to stick to (especially when declaring a bunch of inline data), but it's a really good indicator that a function is getting too long.
@swoopertr
@swoopertr 6 жыл бұрын
this is the best c++ tutorial serie ever! This explains every bit of c++.
@kentroland5182
@kentroland5182 4 жыл бұрын
my lecturer explained it nearly about 1 hour but still we cant understand....thank god i found this channel!!!Thank you!
@jacksonwingdom8683
@jacksonwingdom8683 4 жыл бұрын
same
@seenup9597
@seenup9597 4 жыл бұрын
This series is awesome, i am looking for this type of series.Thank you so much Cherno. Can you please make videos on Concurrency in C++ and also on Design Patterns
@uatignai
@uatignai 2 жыл бұрын
Lol dude, I think am only gonna watch your videos from now. Am a beginner in cpp, but you explain everything so well plus you are funny dude! you def get a follow
@RyanAvgeek
@RyanAvgeek 7 жыл бұрын
The production quality on these videos has really gone through the roof
@deepeshanna
@deepeshanna 7 жыл бұрын
I really hope that this C++ series gets as many audiences as possible !! The best C++ series available on KZbin :)
@MetalWhale.
@MetalWhale. 3 жыл бұрын
I never even heard anything about unsigned variables once in my C++ 1 class. These videos are amazing.
@XxNGameCubexX
@XxNGameCubexX 5 жыл бұрын
Something that almost tripped me off was whether it was necessary to declare a function when compiling a single .cpp file.. after all I had learned in the past that this is the case. Turns out it IS necessary, but the function definition acts as its own declaration as long as it is placed before the entry point (main), which he always does in this video. This had confused me in the video about Header files that comes after. You also don't always have to include the file that contains the definition because of how the linker works. I love these videos. I learned C++ from Mike Dawson's Beginning C++ through Game programming (great book btw, check it out if you're totally new!), but I am watching this to fill some gaps :) Thanks Cherno!
@25fpslagger81
@25fpslagger81 2 жыл бұрын
After watching 10s of videos this small video actually gave me a clear idea about functions
@yickysan
@yickysan Жыл бұрын
Glad to have found this channel and commence my c++ journey.
@dipanshgarg9981
@dipanshgarg9981 2 жыл бұрын
Thanks for existing Cherno....
@d3vr3c4
@d3vr3c4 6 жыл бұрын
I just watch that video stoned, man u are so fucking good teaching. And you have a high level of programming skills. I've never had a idol of programming world, but now i have you as my idol!
@13011tech
@13011tech 2 жыл бұрын
I created a function with a pointer because of this video! This is really good stuff for learning foundational things, especially when self taught. Thank you! +1
@muqasdasyousaf9296
@muqasdasyousaf9296 5 жыл бұрын
Your way of teaching is too much good..... i really like and enjoy it.....
@matheusvieirao
@matheusvieirao 7 жыл бұрын
you make your videos in such a didactic and incredible way that the only thing that makes my learning difficult is the way that your beauty distracts me (and it distracts a lot rs) Thanks for the content!
@craigboger
@craigboger 4 жыл бұрын
Thanks for the series! Great refresher since I haven't had to write C++ in a couple years.
@mahamamjad2864
@mahamamjad2864 2 жыл бұрын
You are amazing.....You have made a C++, a piece of cake for me. Thanks a lot 😍
@Nimitz_oceo
@Nimitz_oceo 7 жыл бұрын
Mr Cherno, first of all I will like to thank you for all the wonderful things you have done for me personally in terms of teaching. Your videos have been beyond what i call helpful, I will like to ask you for some specifications regarding the hardware. For some of the previous series you have done. Series like sparky and building the java game engine. What kind of hardware will you recommend in order to achieve maximum performance while building the game engine
@Xx_McJasper_xX
@Xx_McJasper_xX 3 жыл бұрын
Love it dude. Can't wait to finish the C++ series so I can dive into the Game Engine playlist.
@akshhay
@akshhay 3 жыл бұрын
4yr of college & my teacher could never explain things this easy
@sebve9399
@sebve9399 5 жыл бұрын
your videos are amazing. so many details and answers to common questions!
@HappyMatt12345
@HappyMatt12345 2 жыл бұрын
Any multi-line snippet you end up repeating in several places is probably better to write a function for imo.
@joymakerRC
@joymakerRC Жыл бұрын
bong hits between vids bro, imma be a genius by the end .
@ommahajan1
@ommahajan1 4 жыл бұрын
I like that you have increased the font size so that we can watch on low res or small screens.
@originaltenka5545
@originaltenka5545 5 жыл бұрын
He's really come a long way...I started here congratulations on your wedding
@theturtleclubcanzadywhite3527
@theturtleclubcanzadywhite3527 2 жыл бұрын
omg thank you I just been having trouble lately understanding Functions
@caffeinatedinsanity2324
@caffeinatedinsanity2324 Жыл бұрын
In embedded systems, using functions will also actually make you use less memory. Which is crucial, since you need to manage resources more importantly than with computer science.
@rayecast
@rayecast 4 жыл бұрын
That bit about making mistakes from copy and pasting: my professor, when he was teaching us C, kept telling us that "code duplication is EVIL." He kept saying that, and it's the one thing that really stuck because he kept saying it lol
@Unknown-uq2nc
@Unknown-uq2nc 3 жыл бұрын
It's facts tho
@ioanamarin3242
@ioanamarin3242 7 жыл бұрын
This was so helpful! Thank you for your effort
@andrejilic8106
@andrejilic8106 6 жыл бұрын
You are a god, I really appreciate all of those tutorials and I love your videos! Keep up the good work and if you can make a series on dll coding, i mean like conecting to the pipe and more stuff
@ruicsf
@ruicsf 3 жыл бұрын
Love the videos, thank you. One suggestion; Could you zoom out a bit in the future when writing the code, would help when following along.
@tahasedjal9380
@tahasedjal9380 4 жыл бұрын
This series is magnificent.
@utkarshin
@utkarshin Жыл бұрын
Hey sir your series is amazing your teaching is looks like you have very heavy duty expereince.
@renarsdilevka6573
@renarsdilevka6573 4 жыл бұрын
Would expand on this topic with my experience in Web development, nevertheless, it is writing code daily :). The another important thing apart from readable code and not making spaghetti, therefore applying the solution to split your code into nice functions, is able to write tests for the code. So code which is split into nice little short functions is easier to write tests for, if any needed in given context. It is all about delegation and then writing isolated tests to test your application.
@ahmopasa
@ahmopasa 4 жыл бұрын
I would like to ask a question. At 05:04, the function will create a brand new variable called " result " whenever we call MultiplyAndLog function. In order to avoid creating a brand new variable, should we send a third parameter that will hold the result of multiplication? What is the negative side of doing that?
@KishoreG2396
@KishoreG2396 4 жыл бұрын
@Artem Katerynych Plus the effects of copy elision will most likely get rid of the temporary copy. That is guaranteed in C++17.
@Alex.The.Lionnnnn
@Alex.The.Lionnnnn 3 ай бұрын
You enunciate your words so clearly. I'd sound like a mumbling bogan if I tried to be a youtuber. 😂
@shieng48
@shieng48 2 жыл бұрын
Love these series
@ahujadivyam
@ahujadivyam 7 жыл бұрын
Thanks Cherno
@jamesfox8930
@jamesfox8930 6 жыл бұрын
these videos are a beast bro jackson
@redwheeliq
@redwheeliq 7 жыл бұрын
I won't be surprised if your videos show in college to teach students c++ (sorry for my bad English tho )
@themodernshoe2466
@themodernshoe2466 7 жыл бұрын
The stuff on the compiler/linker is pretty good for interview studying imo
@SimplyWilbert
@SimplyWilbert 7 жыл бұрын
My computer science teacher is assigning us to watch this video and come up with two questions about C++ Functions
@thederickff
@thederickff 7 жыл бұрын
No prob ^, (sorry for my bad English)
@HermanWillems
@HermanWillems 6 жыл бұрын
It's missing alot information about functions. For example passing by reference or value. Passing in functions... and much more. It's just scratching the VERY VERY basics of functions. But good for beginners. But don't expect to understand everything about functions after this video lol.
@Goldfish1060
@Goldfish1060 6 жыл бұрын
Herman Willems No shit, this is obviously a beginner video.
@kishanrajKRJ
@kishanrajKRJ 6 жыл бұрын
its the best video series,ever!
@dorothyglade9087
@dorothyglade9087 5 жыл бұрын
Thanks for this! Super helpful with school!
@minhquando100
@minhquando100 5 жыл бұрын
I usually go by a self-made rule I call the rule of 3. If I have to write a chunk of code that's more than 3 lines long and I have to write the same chunk of code more than 3 times in my codebase, then I'm making a function.
@JoshTheAE
@JoshTheAE 7 жыл бұрын
Thank you!! Wasn't expecting a video in the middle of the week..
@yunusmile
@yunusmile 3 жыл бұрын
not sure if i am more jealous of your hair or your c++ skill
@iamgroot3931
@iamgroot3931 3 жыл бұрын
Why cant it be both?😂
@andreimadroane9579
@andreimadroane9579 5 жыл бұрын
At school our teacher makes us to make every code with a function, even simple ones like: Fibbonacci series and the the least common multiple
@manhvv
@manhvv 6 жыл бұрын
Hi Cherno, I would like to say thank you. You have excellent training skill, and thank god, you give this course free :). Hope you fine.
@escanorplays600
@escanorplays600 3 жыл бұрын
This guy explains like 5 head strat's but my brain cant keep up or understand. i just hope one day i can wrap my brain around it
@ChrisCDXX
@ChrisCDXX 7 жыл бұрын
Damn dude... You have a talent for helping people understand... SUBBED!
@alisonrae
@alisonrae 4 жыл бұрын
Thank you so much! Your videos are amazing!
@michaelkochka7668
@michaelkochka7668 5 жыл бұрын
Love your videos man! Keep it up!
@exnaruto1
@exnaruto1 7 жыл бұрын
Thanks for an awesome second video of the week!!!
@floridaplumber6106
@floridaplumber6106 Жыл бұрын
your videos are perfect at 75 speed, you are wise and fast !
@seymencicek8627
@seymencicek8627 2 жыл бұрын
Thanks for this C++ tutorial!
@Murderface666
@Murderface666 7 жыл бұрын
I think all computer science classes should have music playing in the background instead of stale silence with the sound of keys clacking like its an internet sweatshop
@rynho7255
@rynho7255 7 жыл бұрын
If you hear carefully, there are both in this video and honestly, it's kinda enjoying to hear keys clacking :)
@flopaz6950
@flopaz6950 7 жыл бұрын
Niceeeeee to see a new video in the week!!
@David-And-A-Half
@David-And-A-Half Жыл бұрын
Forgetting to change a variable name after copying costs me half an hour EVERY. SINGLE. TIME.
@Plasticcaz
@Plasticcaz 7 жыл бұрын
An episode half-way through the week? I'm pausing Masterchef for this!
@Nimitz_oceo
@Nimitz_oceo 7 жыл бұрын
Same question. Am I dreaming ? I haven't done my homework. But thank you very much
@anjuro
@anjuro 7 жыл бұрын
Nice intro to functions! although perhaps a bit too basic. I'm looking forward to more advanced topics like the rule of three, modularizing code with unions and templates etc although I suppose those topics have more to do with classes .
@WayneRiesterer
@WayneRiesterer 5 жыл бұрын
Your series is 99.99% perfect. I reserve 0.01% for the opening curly brace on a new line and using an uppercase character for the first letter of a function name. Ahhhh...C#, what have you done to style...? :D
@jgurtz
@jgurtz 5 жыл бұрын
Raising my devops hand here just say: please return useful and sane values from your main (and document them!)! Testing the return value of programs is the fundamental error checking method from within shell scripting or even exec within other programs. By all means create an error handling function or class to organise this.
@배려와겸손
@배려와겸손 6 жыл бұрын
You are amazing! Thanks for the great videos 😍
@Xyral_
@Xyral_ Жыл бұрын
The final product of your multiplication program is actually still messy. Cleaner version which does the same thing: #include void MultiplyAndLog(int a, int b) { std::cout
@krishangopal1803
@krishangopal1803 5 жыл бұрын
love the way you explain.
@sallaklamhayyen9876
@sallaklamhayyen9876 2 жыл бұрын
brilliant explanation thank you so much
@zhh174
@zhh174 4 жыл бұрын
thank you, sir. you explain everything greatly
@kriswitek8883
@kriswitek8883 7 жыл бұрын
Really appreciate the videos, Cherno. Looking forward to each one.
@viktor_borodin
@viktor_borodin 3 жыл бұрын
I want to specify that functions has other various features. They also make interface, self-descripted code, possibility of modular code.
@mracipayam
@mracipayam Жыл бұрын
6 years later from this video i followed you on instagram :D
@justchill99902
@justchill99902 3 жыл бұрын
Me: "Has the Cherno gone crazy?" The Cherno: "Maybe but that's not the point" AHhahahahaah
@TheMastercheeff
@TheMastercheeff 6 жыл бұрын
Another awesome Charno video!
C++ Header Files
15:10
The Cherno
Рет қаралды 742 М.
Stop using std::vector wrong
23:14
The Cherno
Рет қаралды 160 М.
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
REFERENCES in C++
10:13
The Cherno
Рет қаралды 592 М.
The Dome Paradox: A Loophole in Newton's Laws
22:59
Up and Atom
Рет қаралды 1,1 МЛН
So I Added WAY Too Many Slimes to Minecraft...
43:40
Fundy
Рет қаралды 37 М.
How to DEBUG C++ in VISUAL STUDIO
19:20
The Cherno
Рет қаралды 490 М.
Variables in C++
13:46
The Cherno
Рет қаралды 478 М.
you will never ask about pointers again after watching this video
8:03
COMPUTER SCIENCE explained in 17 Minutes
16:49
Wacky Science
Рет қаралды 1,6 МЛН
Magnus Carlsen DISQUALIFIED From World Chess Championship
27:51
GothamChess
Рет қаралды 1,1 МЛН
POINTERS in C++
16:59
The Cherno
Рет қаралды 1 МЛН
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН