CLASSES in C++

  Рет қаралды 685,770

The Cherno

The Cherno

Күн бұрын

Пікірлер: 408
@huntersan9
@huntersan9 7 жыл бұрын
I can't stop looking at the chicken.....
@Maruf-zt7dz
@Maruf-zt7dz 6 жыл бұрын
same
@muhammadasmar7846
@muhammadasmar7846 5 жыл бұрын
i cant unsee that now...
@georgeconstantinides1947
@georgeconstantinides1947 5 жыл бұрын
lol I didn't even notice it
@xuqiangzhang9724
@xuqiangzhang9724 5 жыл бұрын
lol
@sing759
@sing759 5 жыл бұрын
the same here
@xyz8206
@xyz8206 4 жыл бұрын
3:43 'variables that are made from class types are called objects' this line just made everything so much easy. Thank you.
@nikhilgarg27
@nikhilgarg27 Жыл бұрын
Agreed with you 100%
@electronix259
@electronix259 6 жыл бұрын
Each of these 10 minute videos teach me more than one class
@themanwhich123456
@themanwhich123456 5 жыл бұрын
fuck yeah.
@CupOfWhiskey
@CupOfWhiskey 4 жыл бұрын
No joke, I learned more in two videos 16min total than I did in my 2hr class
@timeflies98
@timeflies98 4 жыл бұрын
glad I'm not the only one
@michaelnolan8719
@michaelnolan8719 3 жыл бұрын
Professor Xing ain't got nothing on Cherno, Easy A for data structs. ;)
@pierfrancescopeperoni
@pierfrancescopeperoni 3 жыл бұрын
True, you can play videos faster on KZbin.
@zzzMrgamerzzz
@zzzMrgamerzzz 5 жыл бұрын
Never in my Uni days have I seen such a good youtube tutor. Clear, succinct and everything seems so much simpler
@serkanozturk4217
@serkanozturk4217 2 жыл бұрын
Personal notes: -Members are private by default -Classes allow us to group variables into a user-defined type and also add functionality to those variables
@goodvibes7304
@goodvibes7304 Жыл бұрын
And those functions are called methods inside the classes.
@oquaika-qua3043
@oquaika-qua3043 4 жыл бұрын
Coming from a C background and just learning C++, I have had so many people try to explain the concept of classes, but until watching your video I have never fully understood it. Thank you so much.
@rzmadzore
@rzmadzore 2 жыл бұрын
same here, what a relief
@mtareen
@mtareen 5 жыл бұрын
I wish learning C++ was this easy. Having worked in C++ for 8 years in the past, it takes a long time to understand these concepts
@ToxicityGameDev
@ToxicityGameDev 7 жыл бұрын
Soooooo.... Udemy ads keep playing on these videos telling me to sign up for a C++ course on there... Pfff, wrong place to advertise guys lmao.
@Gilpow
@Gilpow 6 жыл бұрын
Sure, because clearly you're going to learn a lot by using a single source, right?
@timmoth_j
@timmoth_j 6 жыл бұрын
Using an adblocker will stop the Cherno from earning money from these videos, regardless of how smug and annoying the Udemy guy is I still choose to watch the adverts to support the Cherno.
@Gilpow
@Gilpow 6 жыл бұрын
Timothy Jones Yup, it's the least we can do, if we can't support him on Patreon.
@batabatonica
@batabatonica 6 жыл бұрын
They are spamming me python and html, but i watch them anyway to help Cherno
@ToxicityGameDev
@ToxicityGameDev 6 жыл бұрын
@Gilpow, really dude... you take all of life so serious? @Dany na, I prefer to help him get those pennies that stack up from the ad views ;-)
@faizalimuhammadzoda4731
@faizalimuhammadzoda4731 7 жыл бұрын
I like the way you explain things: very simple, very fast and most importantly-nothing outside the topic. Thanks.
@mukundchandrahasan5890
@mukundchandrahasan5890 6 жыл бұрын
Just came by to learn more from my University C++ class, and I got to say I love how your video is succinct and concise. No extra flowery wording, just straight to the point. But you do so in a way where we can understand, so you have that perfect sweet spot in teaching. Appreciate it, and I'm glad I came across your channel.
@zes3813
@zes3813 3 жыл бұрын
wrgg, no such thin gas extra or succx or concisx or point or etc, say, can say infix any nmw and any s perfect
@biqbicle4982
@biqbicle4982 Жыл бұрын
@@zes3813 ??
@nortski78
@nortski78 4 жыл бұрын
I'm so glad you decided to ease up on the music, it makes it so much easier to concentrate on what you're saying.
@leixun
@leixun 4 жыл бұрын
*My takeaways:* Class is a way to group data and functionalities together 0:55
@rasta6332
@rasta6332 4 жыл бұрын
looking for your comment and found it... I hope you have a summary of all the upcoming videos in the playlist.
@leixun
@leixun 4 жыл бұрын
Rasta Thanks, I did write summary for most videos in the playlist, but some of them are more complete than others :)
@Aditya-zl8sn
@Aditya-zl8sn 3 жыл бұрын
commenting for visibilty
@colorlord98
@colorlord98 7 жыл бұрын
Still waiting for that video on the back of a kangaroo!
@dildarsk246
@dildarsk246 7 жыл бұрын
Cherno becomes teacher. 100% boys' attendance. *200%* girls' attendance. *H a n d s o m e*
@amndrkwe
@amndrkwe 4 жыл бұрын
Michael O'Connell if you count us it would be probably 500%
@essmunson
@essmunson 4 жыл бұрын
@@amndrkwe agreed
@RoySATX
@RoySATX 4 жыл бұрын
More like 110% boys attendance, I know I'd be auditing this course
@iamtrash288
@iamtrash288 4 жыл бұрын
Shadow clone no jitsu
@suntzu1409
@suntzu1409 3 жыл бұрын
Gaes: ( ͡° ͜ʖ ͡°)
@FlooferLand
@FlooferLand 3 жыл бұрын
1:42 "You can probably start to *C* that this is getting a little bit messy" and that relates to how C doesn't have classes lmao
@humbledcomposer
@humbledcomposer 9 ай бұрын
A side note. If you were to print x or y in the state of the code at 8:03, you would get a completely unknown value. This is because, as he talked about in previous videos, when the variable is created it get assigned a memory address. We have no idea what previous data was in that memory address, it could be anything. Thus, if you print it without initializing it, most often, it will be a seemingly random integer value left over from the last variable (even from another program) that used it. As a result, ALWAYS initialize your variables people. ALWAYS.
@autumnleaf8483
@autumnleaf8483 3 жыл бұрын
This is like Roblox Studio Development where everything has a classname, with its own functions! Thanks for the tutorials! I am loving it!
@christophersheppard3249
@christophersheppard3249 3 жыл бұрын
Wow, in 8 minutes you managed to teach me better than my actual cs teacher.
@danielrousseau6541
@danielrousseau6541 6 жыл бұрын
This kind of format is definitely better for both teaching and learning.
@gurjindersingh3843
@gurjindersingh3843 4 жыл бұрын
C++ is called C++ because in C "++" was used to increase the value of variable by 1. So if C=1. C++ = 2. Which is to say, C++ is an incremented improved version of C.
@gurjindersingh3843
@gurjindersingh3843 4 жыл бұрын
@Artem Katerynych I forgot ++C was a thing
@Ferocious_Imbecile
@Ferocious_Imbecile 2 жыл бұрын
It's always a relief to find somone that makes an impermiable thicket of jargon become meaningful.
@accessdenied9393
@accessdenied9393 3 жыл бұрын
Or more simply, we can declare the move function inside the class and define it outside the class. class Player { public: int x, y; float speed; void Move(int xa, int ya); }; void Player::Move(int xa, int ya) { x += xa * speed; y += ya * speed; } int main(void) { Player player; player.x = 1, player.y = 2; player.speed = 3.4; player.Move(1, 2); }
@jmac217x
@jmac217x 2 жыл бұрын
In 3 min you've explained classes better than anyone and with examples of references too kudos
@Hydro1738
@Hydro1738 5 жыл бұрын
Dude, your explanations are really impressive ... I like your KISS approach ...
@vidyutphagetra3804
@vidyutphagetra3804 3 жыл бұрын
you have a gift of explaining things precisely and without all the bullshit
@benixmo
@benixmo 4 жыл бұрын
I've been using python and golang but honestly I am going to use C++ from now on. Literally every video you have with a "new" concept just leave me thinking "Wow that's really cool", C++ seems like the perfect language.
@tomjesten3945
@tomjesten3945 4 жыл бұрын
Depends on what you want to do with C++.
@kylekastilahn
@kylekastilahn 3 жыл бұрын
If you're learning to code any of these are fine to learn in C++/C#/Python/Java/Javascript in my opinion. I would recommend playing around with a few of them just to get a feel for what you like. I wouldn't worry so much about "learning" the language, as much as learn to code, to start off because a lot of the basics/concepts are very similar. As one progresses it really depends on what is your path / end goal (use the right tool for the job). Each language is a tool, there are pluses and minuses to each. Personally would recommend Python/C#/Javascript to beginners because I think they are the most straight forward and have many branches and uses one can do particularly if you're not sure of your path.
@MrHaggyy
@MrHaggyy Жыл бұрын
There is one thing that classes do automatically for you that's quite hard and not fully achievable by C. And that's typesafety at compile time. You can typedef structs in C, but you can walk around the typecheck by accident or on purpose. C++ on the otherhand will always give you an compile error if you work with object's of different types, unless you provide a function or overwrite an operator that gives meaning to that combination of types.
@rachidajewher8649
@rachidajewher8649 3 жыл бұрын
i like the way you are teaching people you are explaining everything in a higher speed you get the global vision of the subject instantly
@akberalikhan4659
@akberalikhan4659 4 жыл бұрын
Explained it quickly and clearly. Saved me a lot of time. Thanks!
@bencilbusher5070
@bencilbusher5070 3 жыл бұрын
it wasn't until I watched this video did I finally understand exactly why OOP is easier. thanks to juxtaposing the function straight to the class function.
@isaacyuki1
@isaacyuki1 4 жыл бұрын
wow u actually simplified 24h of senseless lectures in 8 min.
@sacredgeometry
@sacredgeometry 4 жыл бұрын
C# is most certainly not just OO anymore its definitely well seated as a multi-paradigm language and has been for many years. With things like ReactiveX you have data-flow, with LINQ you have functional, both are those are heavily declarative but c# is obviously also heavily imperative, reactive is data driven but async/await sand the TPL is task driven, it has very mature reflection it can easily be written procedurally. It is basically the programming language equivalent of what English is to spoken language. It takes good ideas, finds really robust implementations and then improves on them.
@emilycs8823
@emilycs8823 3 жыл бұрын
These videos make these concepts so simple. I learn more from them than my professors lectures , and college c++ textook.
@iamzepeqeno5086
@iamzepeqeno5086 2 жыл бұрын
me: oh so a class is to organize data ? cherno: no... *sight* not data, its DADA
@jaidev2717
@jaidev2717 4 жыл бұрын
Can't appreciate this series enough..excellent job...Best things is your videos aren't boring like other programming videos. Keep it up man. May god bless you.
@swapnilkarmakar3299
@swapnilkarmakar3299 2 жыл бұрын
5:10 Can someone explain why did he take Player& player in move function as a one of the parameters.
@mohit7717
@mohit7717 4 жыл бұрын
thank u so much for providing this c++ series .
@roja
@roja 3 жыл бұрын
Commenting for your exposure. The best channel on KZbin for C++ !!!
@jonathanlevin7660
@jonathanlevin7660 3 жыл бұрын
About C# being exclusively Object-Oriented - While it's true that C# was originally made to be an cleaner, object oriented alternative to Java, It's actually moving more and more to the functional paradigm in recent years, including borrowing many features from F#. Also I'm not a Java dev but pretty sure it also has Lambdas as of Java 8, though afaik on the JVM there are other languages much preferred for functional programming (Scala, Kotlin etc)
@chastitywhiterose
@chastitywhiterose 5 жыл бұрын
I've done many hobby programming projects over the years and yet I've stuck with C and never used object oriented features. However I have seen this and other examples of how it can allow doing the same things I'm doing in a lot less code. I'm doing graphics programming and so an image class makes sense as each image will have its own pixel array and width and height.
@PythonisLove
@PythonisLove 3 жыл бұрын
youtube sucks, it didn't recommend your video, while I was actually learning c++, now it's again making things interesting!
@r0_
@r0_ 5 жыл бұрын
This is the best explanation i've seen. every video/tutorial didn't help me. i tried for a few months but this is the only one i consider good
@ezert_13
@ezert_13 5 жыл бұрын
I'm sure I'll recommend this course for a lot of people in the future! : D
@chalkchalkson5639
@chalkchalkson5639 7 жыл бұрын
"there is nothing you can do with classes you couldn't do without them" Yeah, C is turing complete and doesn't have classes, but so is assembly or colouring squares on a piece of paper... Just because you could technically do all the same things doesn't mean that anyone on earth is actually capable of doing so :P
@i.donthaveanameanymore
@i.donthaveanameanymore 7 жыл бұрын
C still has things like structs, function pointers, etc. that can accomplish any OOP stuff in about the same amount of code. As opposed to, e.g. templates, which have no real correspondence with any C features.
@zfolwick
@zfolwick 4 жыл бұрын
You can actually define classes in C. But why would you want to? It important to know in legacy codebases
@suntzu1409
@suntzu1409 3 жыл бұрын
( ͡° ͜ʖ ͡°)
@rando521
@rando521 Жыл бұрын
you are extremely coherent and i love it.
@cheako91155
@cheako91155 5 жыл бұрын
C also has objects these are singular, structures, and arrays. Any of them could hold a pointer to a function and when u call a function through such a pointer that's exactly when things transition into OOP.
@allengeringer574
@allengeringer574 2 жыл бұрын
As soon as youtube decides to offer an accredited degree, my University will loose the ability to provide the last thing they still offer to students: the actual piece of paper.
@Rose_Harmonic
@Rose_Harmonic 3 жыл бұрын
my brain is exploding with understanding and I am very excited.
@bayroncastillo7653
@bayroncastillo7653 6 жыл бұрын
you are so good at explaining , thank you
@nemanjakatava4735
@nemanjakatava4735 3 жыл бұрын
found your tutorials very useful, well done
@mojosace
@mojosace 6 жыл бұрын
Genius. Learned more in this than in one whole lecture with my awful professor
@minecetinkaya5763
@minecetinkaya5763 Жыл бұрын
Perfect!!!!! How could you explain so simple. I read and watched videos but this is the most understandable way of this topic. Thank you so much.
@ShadowLogic3253
@ShadowLogic3253 5 күн бұрын
I love how he's making classes look like the greastes thing ever here when in most of his code reviews he says something along the lines of " *sigh* C++ is a functional language and doesn't need classes so its probably a good idea to start moving away from oop." 😂😂
@SyedAbdulBasit-n6p
@SyedAbdulBasit-n6p Жыл бұрын
this video really helped me understand Classes in C++ thanks cherno♥
@pewpew4663
@pewpew4663 7 жыл бұрын
For a split second I thought there was a real chicken behind you just chillin there.
@SkeletonSSBM
@SkeletonSSBM 3 жыл бұрын
Thank you so much! Simple and to the point, yet has great explanations for the things he's doing. Nice work!
@rcookie5128
@rcookie5128 7 жыл бұрын
Structs could have been mentioned as well in this video I guess, but not necessarily. Great job, as always! now to the other columns of OO programming! :)
@SabrinaOwens-i7s
@SabrinaOwens-i7s Жыл бұрын
Thank you for simplifying classes for me in c++
@nabinshrestha7834
@nabinshrestha7834 3 жыл бұрын
make video on data structure and design and analysis of algorithm
@NoThing-ec9km
@NoThing-ec9km 4 жыл бұрын
there are actually things u cant practically do without classes that is changing variables already assinged without rewriting the whole code so its technically possible to rewrite whole code but given that u dont wanna do that so u cant do it without classes
@SolarPlayer
@SolarPlayer 4 жыл бұрын
I had a negative reaction to this vid in the first couple of seconds because I'm a superficial moron but I was a fanboy by the end. What a great explanation and high quality vid, impressive
@darikostov9583
@darikostov9583 4 жыл бұрын
I am making a game in which i am trying to keep my code tided up by using classes for every character but when it comes to two characters to interact i have problems accessing the other class
@luobei5083
@luobei5083 3 жыл бұрын
group the variable into a type and add functionality to those variables.
@dalyzee
@dalyzee 6 жыл бұрын
You just earned a sub.
@skayland
@skayland 3 жыл бұрын
Wow that was super simple and well explained. i think I'm gonna watch the whole series now lol
@fsk648
@fsk648 7 жыл бұрын
You kinda look like Luke Steele from Empire of the Sun, you even have the same nationality. Keep up these golden tutorials man.
@reviIo
@reviIo 4 жыл бұрын
tell me why this video explained things better to me than 3 hour long lectures of just abstract ranting
@AlexTheGreatish
@AlexTheGreatish 6 жыл бұрын
That hair is on point in every video.
@zes3813
@zes3813 3 жыл бұрын
wrrr
@thoraero
@thoraero 2 жыл бұрын
I really hope 14 year-old me some 20 years ago watched this. I struggled so much back then with so little access to materials.
@azriel__
@azriel__ 5 ай бұрын
MAN I LOVE THE CHERNO
@calecacciatore5422
@calecacciatore5422 6 жыл бұрын
Hey Cherno, trying to get back into the programming world, a few questions popped into my head : what do you think about Data Oriented Design (vs. Object Oriented) ? How effective can one use and understand DOD vs OOP ? or should i just stick to procedural kind of programming, that is, use C++ only where needed and mostly stick to C ? I want to be able to understand the computer and what it is doing for performance reasons. What s the speed difference in those applications between the two designs ? there s just not many resources around to poke into.
@anandchourasia1848
@anandchourasia1848 2 жыл бұрын
Hey Cherno, you can't do this!!! You are making C++ too easy.
@yahiashams2334
@yahiashams2334 3 жыл бұрын
So a class is essentially a struct that can have functions.
@crashtagiyevpirt
@crashtagiyevpirt Жыл бұрын
​@Artem Katerynych And Struct is in Stack andClasses in Heap
@siddhitasethmadan6388
@siddhitasethmadan6388 4 ай бұрын
Even a struct can have functions.
@yuyu-ce4fz
@yuyu-ce4fz 5 жыл бұрын
How do I delete same name which highlight code at the same time? 6:10 thanks.
@suvrec
@suvrec 4 жыл бұрын
I am dying to know... did you find it out??? Can't find that shortkey anywhere!
@fastlearner292
@fastlearner292 Жыл бұрын
​@@suvrecya'all found it out?
@SnackKingOfficial
@SnackKingOfficial 3 жыл бұрын
I learned so much from this video, the confusion and worry I had is gone.
@sumitkamble_
@sumitkamble_ Жыл бұрын
No more confusion with classes again
@streetfighteryamahar178
@streetfighteryamahar178 5 жыл бұрын
Very clear and understandable video with relevant examples. Thank you.
@josiahjoel7580
@josiahjoel7580 3 жыл бұрын
you said that C doesn't support object oriented programming but classes seem identical to structs in C?
@Evan490BC
@Evan490BC 3 жыл бұрын
No, not really. C++ structs can have methods, unlike the C ones. (These methods will be public by default.)
@jandynotaloca
@jandynotaloca 4 жыл бұрын
thank you so much, every other video doesn't explain it thoroughly.
@Get_Boros
@Get_Boros Жыл бұрын
Nice example of POD (Plain Old Data) type.
@chiyungchu9463
@chiyungchu9463 4 жыл бұрын
use alt+ up arrow to move selected line up in case u dont know .(go to Edit > Advanced)
@mustafaglnr8780
@mustafaglnr8780 5 жыл бұрын
Any thought you have, to build up an episode relative with Polymorphism ? if no, please ...
@Jonas.verhaegen
@Jonas.verhaegen Жыл бұрын
How can we do what you just wrote without classes? I mean, that's probably quite easy as it is a simple example. How would you actually do that though? Would that be possible by creating a global container that stores the player identifier key like in a , and then maybe associate x, y, speed with that key? How would we actually do that though with a map? I only learned it so far that you can associate 2 datatypes with each other, so let's say a string for the identifier, and then int for the x location. Or maybe even a map that associates a string key with a double vector? This vector could then hold x, y and speed. This way we could create various players inside our map and set x,y,speed independantly for each player. And then create some fuctions to perform transform operations on the player's position where we just need to input the playeridentifier key and displacement variables and it will automatically alter the vector content that responds to the identifierkey? I'll try this experiment now. But though, I can imagine if you would need to perform more complex algorithms on a certain custom datatype, it would be almost impossible to do that without having classes. Not impossible I believe, but just over the top unnecessary complex.
@mohit7717
@mohit7717 4 жыл бұрын
Please provide a lecture on Data Structure and Algoerithms pls pls
@NurGarciaTerrassa
@NurGarciaTerrassa Жыл бұрын
Great lesson! Thank you!
@omer204
@omer204 Жыл бұрын
Only an expert can tell these concept as easy as possible as you
@johnjoyce
@johnjoyce 5 жыл бұрын
Wrong at 0:47. In C you have to create the whole mechanism. structs do it.
@javand86
@javand86 2 жыл бұрын
So easily understandable. Subbed
@primalpimmy
@primalpimmy 5 жыл бұрын
You sir, deserve more Subs.
@sidharthsk84
@sidharthsk84 Жыл бұрын
really helpful and resourceful.
@TerranIV
@TerranIV 2 жыл бұрын
Thanks for this great overview!!!
@shrikant_paliwal
@shrikant_paliwal 3 жыл бұрын
Bohot hi Pyara Explanation. (Really Nice Explanation of the concept). Thank You
@mardiyonghasben1619
@mardiyonghasben1619 Жыл бұрын
thanķ you sir....and godbless you...give all human education about and learn programming c++...thank you
@aideenfay3055
@aideenfay3055 6 жыл бұрын
Thank you so much
@dxlge
@dxlge Жыл бұрын
My notes: A class is a way to group data and or functionality together. We can use a class which contains all of our data into this one type. Our class needs to be a unique name. Variables that are made from class types are called objects and a new object variable is called an instance. Private and pubic is something that we can use in our classes, its main purpose is for visibility. Data and methods that are declared under public can be accessed outside of our class where as anything declared under private is the complete opposite, it can only be accessed inside of that class. Classes can contain functions, we call functions inside of a class a method. To conclude what a class is, it allows us to group variables together into a type and also add functionality to these variables (our private members). We essentially have data and have functions to manipulate this data. Anything that can be done with classes can be done without them, they make our life easier as a programmer and give us the ability to maintain code much better
@GenericPhantom1
@GenericPhantom1 2 жыл бұрын
Classes are a way to group data and or functionality.
@nikudayo7927
@nikudayo7927 2 жыл бұрын
"functions inside classes are called methods". OMG I've been using those words interchangeably this whole time! :o
@AshleyTyagi
@AshleyTyagi 5 жыл бұрын
Isn't it called encapsulation when you put data and methods together using a class??
@eugenecbell
@eugenecbell 3 жыл бұрын
the light bulb goes off! thank you.
@CyroCh.
@CyroCh. 2 жыл бұрын
didn't know that using &x will modify the actual value lol i used pointers and... ty
CLASSES vs STRUCTS in C++
8:32
The Cherno
Рет қаралды 481 М.
POINTERS in C++
16:59
The Cherno
Рет қаралды 1 МЛН
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН
How to Write a C++ Class
11:32
The Cherno
Рет қаралды 421 М.
Is C BETTER than C++ for beginners? // Code Review
31:16
The Cherno
Рет қаралды 84 М.
Stack vs Heap Memory in C++
19:31
The Cherno
Рет қаралды 584 М.
REFERENCES in C++
10:13
The Cherno
Рет қаралды 592 М.
How I Mastered Data Structures and Algorithms in 8 Weeks
15:46
Aman Manazir
Рет қаралды 133 М.
COMPUTER SCIENCE explained in 17 Minutes
16:49
Wacky Science
Рет қаралды 1,6 МЛН
How the C++ Compiler Works
17:55
The Cherno
Рет қаралды 831 М.
Templates in C++
17:58
The Cherno
Рет қаралды 606 М.
Weak Pointers in C++ (std::weak_ptr)
17:25
The Cherno
Рет қаралды 60 М.