Inheritance in C++

  Рет қаралды 391,711

The Cherno

The Cherno

Күн бұрын

Twitter ► / thecherno
Instagram ► / thecherno
Patreon ► / thecherno
Slack ► slack.thechern...
Series Playlist ► • C++
BEST laptop for programming! ► geni.us/pakTES
My FAVOURITE keyboard for programming! ► geni.us/zNhB
FAVOURITE monitors for programming! ► geni.us/Ig6KBq
MAIN Camera ► geni.us/t6xyDRO
MAIN Lens ► geni.us/xGoDWT
Second Camera ► geni.us/CYUQ
Microphone ► geni.us/wqO6g7K

Пікірлер: 239
@KE010101
@KE010101 4 жыл бұрын
I'm learning C++ now, and these videos showing the code being written while explaining the concepts are most valuable.
@appsenence9244
@appsenence9244 Жыл бұрын
Yes that is the definition of a tutorial and the reason we are all here. But thanks for stating the obvious.
@KE010101
@KE010101 Жыл бұрын
@@appsenence9244 🧡
@KE010101
@KE010101 Жыл бұрын
@@appsenence9244 your absolutely correct, thanks for pointing that out, 🧡
@appsenence9244
@appsenence9244 Жыл бұрын
@@KE010101 that'll be 5 bucks
@KE010101
@KE010101 Жыл бұрын
@@appsenence9244 🤣🤣
@mikeock3164
@mikeock3164 4 жыл бұрын
I'm a Computer Science major and with the whole online learning thing, its been a but hard to learn things. Thanks for these videos !! They really are a big help.
@darksquirrel7436
@darksquirrel7436 4 жыл бұрын
yeah i will have an exam in 5 days and i haven't attended a class in weeks if it weren't for these videos i would have to learn from the teacher's powerpoints which are crap
@Thadnill
@Thadnill 4 жыл бұрын
@@darksquirrel7436 I have exam tomorrow and crammmiing these videos as **** haha
@mryup6100
@mryup6100 4 жыл бұрын
In my area we are already on break.
@darksquirrel7436
@darksquirrel7436 4 жыл бұрын
@@Thadnill Good luck i also have my programming exam tomorrow LOL Edit: I passed the exam and btw if you have to take a java exam don't think c++ is similar because it is not
@Thadnill
@Thadnill 4 жыл бұрын
@@darksquirrel7436 Lol it became an all - nighter for me, I haven't slept yet and my exam is in 2 hours, I might have to do it again after summer, haha well good luck to both of us!
@mr.budders8740
@mr.budders8740 3 жыл бұрын
Your tutorials are great, you edit out when your not talking to reduce the tutorial time making learning faster. You also talk fast and don't stutter also reducing the time. Its quick and concise unlike some people that don't do any editing and just talk without much idea of were they are going from there.
@JawwadHafeez
@JawwadHafeez 4 ай бұрын
Had been programming since decades and love ur description. It gives a new way of thinking and understanding.
@yuchen3587
@yuchen3587 5 жыл бұрын
I go back and watch these videos every time I forget something. And Cherno always gives me the answer
@serkanozturk4217
@serkanozturk4217 2 жыл бұрын
Personal notes: - Example: “Cat : Animal” now Cat class has not only type cat but also has type Animal. That is, it is actually both of those types -Polymorphism ~= being able to use the same fuction for different type of objects thanks to inheritance
@rufusprime0015
@rufusprime0015 4 жыл бұрын
you explain things so clearly and concisely, really helps with my c++ textbook and examples for class. The textbook is actually great but this video is more compressed and helped me get a clear understanding easily. I tend to use these videos as a supplement to what i'm learning in class and it helps so much. Thank you for taking the time to explain this.
@billiatosdaughter
@billiatosdaughter 3 жыл бұрын
please share the textbook
@exnaruto1
@exnaruto1 7 жыл бұрын
"oh man, this hair today, it's just, just perfect" - xD. I love it. xD
@我有一个朋友-i2u
@我有一个朋友-i2u 4 жыл бұрын
could move on to be a fashion vlogger as well, hahaha
@piyushphodu
@piyushphodu 4 жыл бұрын
even though i know 99% percent of these stuff, i still watch the whole video for cherno's wisdom nuggets
@EtBukaneluu
@EtBukaneluu 3 жыл бұрын
could we just move printName to entity class ? and how its gonna look like ?
@mohamedfouzibenreguia8343
@mohamedfouzibenreguia8343 3 жыл бұрын
@@EtBukaneluu you can do that. but in the example we don't need name for entity class. but we need create new class "player" has name & printName function because player have a name. but entity class didn't need a name yes ,you can move printName to entity class but you are entering function you do not need
@liminal27
@liminal27 2 жыл бұрын
This is a great point - hearing even the simplest stuff that you already know from someone very smart like Cherno reinforces your understanding and can even reveal that you don't know it as deeply as you thought. 👍
@martiananomaly
@martiananomaly 2 жыл бұрын
yessir
@josephh8117
@josephh8117 2 жыл бұрын
Cherno has helped me massively in my CS education these last few years. Thank you so much, my Ozz brotha.
@dxlge
@dxlge Жыл бұрын
Notes: Inheritance is one of the most fundamental and powerful part of classes. It allows us to have a hierarchy of classes which relate to each other, it allows us to have a base class which contains common functionality and then it allows us to branch off from that class and create sub-classes from that initial parent class. The reason why this is so useful is because it allows us to avoid code duplication. Instead of us repeating ourselves over and over again we can put all of our common functionality between classes into a parent class and then simply make sub-classes from that base class, which either change the functionality in subtle ways or introduce new functionality. The idea behind inheritance is that it gives us a way to put all of our common code into a base class so we don’t have to repeat ourselves.
@JacobKrajewski
@JacobKrajewski 5 жыл бұрын
Love the way you explain these things. The way you explain things is exactly the way I like to learn. Very talented teacher. Thanks
@ikemkrueger
@ikemkrueger 2 жыл бұрын
You‘re doing a very good job at explaining the things. Thank you for sharing that with us.
@mahlecyrus3960
@mahlecyrus3960 2 жыл бұрын
YOU HAVE EARNED ALL MY RESPECT , I AM LEARNING EXCITING THINGS FROM U SINCE 2019 WHEN I STARTED C++ FROM TIME TO TIME IF DONT UNDERSTAND SOMETHIN I COME TO THESE VIDEOS OF YOURS ,YOUR VIDEOS ARE APPRECIATED
@mahdishirazi5785
@mahdishirazi5785 2 жыл бұрын
this guy is amazing, taught me something in 8 minutes that my teacher failed to do in a whole semester
@maxim25o2
@maxim25o2 3 жыл бұрын
This is exactly what i learned, is avoiding of code duplication, but many peoples doing tutorials don't understand that and they do it opposite way. Misleading many peoples who want learn inheritance.
@LightPenStudio
@LightPenStudio 4 жыл бұрын
That light coming through the window is somehow ethereal.
@joeman123964
@joeman123964 4 жыл бұрын
biggest issue with my murach's textbook. it tries to teach inheritance with a MASSIVE project of code. having a base class with 4 subclasses and other forms of nested functions without showing the entire code. this video kept it simple to teach the basic principle of inheritance. well done.
@kietdo4379
@kietdo4379 3 жыл бұрын
Fast, summarize and precise. Good job man. Love to know you
@matthewe3813
@matthewe3813 3 жыл бұрын
After watching this video, I finally understand inheritance. All of the other tutorials just made no sense to me.
@AhmetYusufYatkin
@AhmetYusufYatkin 4 жыл бұрын
Speedrun of learning. I loved it :D
@yuchen3587
@yuchen3587 5 жыл бұрын
Excellent. It is good to have this video and have a look at it every time I forget something.
@Jester8890
@Jester8890 5 жыл бұрын
Just found your channel studying for my data structures exam, really great content! I'll be checking out the rest soon!
@tannerbarcelos6880
@tannerbarcelos6880 5 жыл бұрын
How’s data structures? I’m going into it this fall. Been killing my c++ class all semester till I got to copy constructors and now into inheritance and polymorphism
@Jester8890
@Jester8890 5 жыл бұрын
@@tannerbarcelos6880 Best way to describe it for me is, it is difficult but very rewarding. It kind of adds several different tools to your tool belt and helps you approach problems with a different view; instead of just brute forcing the solution you think of what would be the best data structure to solve the task. I'm still not 100% comfortable with certain things and I'm towards the end of the semester, but, I think having a better understanding on a more shallow level of what is available I can use the information to dive deeper in during certain situations. Let me know if you have any questions this fall, happy to learn more with you.
@IsaacC20
@IsaacC20 Жыл бұрын
I've had this model for understanding inheritance for years. It's adequate until you learn about multi-ctor call and ctor initializer list, polymorphism vtables/vptrs, object slicing problem, and multi-inheritance and the diamond-inheritance problem. You then have to refine this basic understanding of inheritance to include the idea of "subobjects": if B inherits from A, it's not that B just has members from A, B actually "owns" a subobject of type A. In addition, to create a B object, the ctor of A must be called to initialize B's A subobject. Subobjects can be seen in visual studios while step debugging. When you inspect a B object, you'll see that it contains an A subobject!
@WayneRiesterer
@WayneRiesterer 5 жыл бұрын
class BjarneStroustrup { // stuff }; class TheCherno : public BjarneStroustrup { // extra stuff };
@Karlemilstorm
@Karlemilstorm 4 жыл бұрын
I dont know about that xD I think Bjarne Stroustrup > The Cherno(*anyone else)
@smileynetsmileynet7922
@smileynetsmileynet7922 4 жыл бұрын
I hope I'm thought of that way someday.
@mmaranta785
@mmaranta785 3 жыл бұрын
That guys book on C++ is mind boggling
@mmaranta785
@mmaranta785 3 жыл бұрын
Both hated combs
@song5030
@song5030 7 жыл бұрын
Hey Cherno! Love you're videos man, please keep it up! I am quite experienced with C++, been programming for almost 4 years now. I just have couple of question regarding these tutorials. Are these tutorials going to be made with c++14 or up standart in mind? I find it really hard to find quality modern C++ tutorials online.
@haroldcarter8366
@haroldcarter8366 5 жыл бұрын
did this man just explain polymorphism in 23 seconds? (mind = blown)
@abod4gamer
@abod4gamer 4 жыл бұрын
3:09 Schrodinger's cat
@j0n1
@j0n1 3 жыл бұрын
"Types in C++ are quite a complicated topic because on one hand they don't really exist, however on the other hand they kind of do." is just perfect.
@pimp2570
@pimp2570 6 жыл бұрын
Thank you for explaining it that well, this looks super useful.
@dilute6980
@dilute6980 5 жыл бұрын
Perfect example. The example of having different entities inheriting from 1 main class for the generic entity stuff makes complete sense
@valizeth4073
@valizeth4073 6 жыл бұрын
You should have covered the protected keyword
@arnmazing3156
@arnmazing3156 5 жыл бұрын
Vali Zeth protected just means anything that isn't a child of the parent class can't have access to that class member.
@valizeth4073
@valizeth4073 5 жыл бұрын
@@arnmazing3156 I know, I know. But in a video about inheritance and sort of visibility, the protected keyword should be explained, even though it's simple.
@nishithbaravkar7549
@nishithbaravkar7549 3 жыл бұрын
stop cribbing .. you could just ask the viewers to learn about it in a cinstructive way
@russellcannon9194
@russellcannon9194 5 жыл бұрын
Hey Cherno, I have been enjoying this series on C++ and learning a lot from you, but as far as I can tell, you have not done a video on polymorphism like you suggested you might in this video. I would love to see that from you. Cheers, Russ
@TimPatDuDe
@TimPatDuDe 4 жыл бұрын
Thank you for making this.
@Ebiko
@Ebiko 2 жыл бұрын
Really good video. Can you explain why ` class Player : public Entity ` needs the public, whats the purpose of the "public " ?
@RandomGuyyy
@RandomGuyyy 7 жыл бұрын
That lens effect is like the default post processing setup in Unreal but with better bokehs.
@HermanWillems
@HermanWillems 6 жыл бұрын
Is there also a video about Composition... i mean they say try to avoid Inheritance as much as possible. Use composition.
@WaqarKhan-mw2de
@WaqarKhan-mw2de 6 жыл бұрын
Really awesome, Thankyou so much dear
@Omar.Alamoudi
@Omar.Alamoudi 4 жыл бұрын
Question: So if we have two classes split between 4 files, two headers and two cpp files, we only need to use #include in the child class?
@mikeandjamiejarboe7211
@mikeandjamiejarboe7211 3 жыл бұрын
How/Why do the variables X, Y get initialized to 0? player.X = 0; player.Y = 0; Yet, entity.X and entity.Y are uninitialized???
@vegansynths7757
@vegansynths7757 4 жыл бұрын
This was your clearest video yet.
@bradcasper4823
@bradcasper4823 2 жыл бұрын
I get an error with code below. Does ":" sign copy contents of "father class" into its child? #include using namespace std; class Entity {public: int X, Y; Entity(int x, int y) { X = x; Y = y; ShowPos(); } void ShowPos() { cout
@ymahmoodi5817
@ymahmoodi5817 4 жыл бұрын
Your videos are perfect. It would be great if you made video about multiple inheritance! Thank you.
@AgentM124
@AgentM124 7 жыл бұрын
What happens if you change "public Entity" into "private Entity"? does private make all the Entity fields and methods only accessible to player?
@dekrain
@dekrain 7 жыл бұрын
Agent M it will be only visible to Player class' methods
@AgentM124
@AgentM124 7 жыл бұрын
so if public banana() in Entity then it won't be visible to anything but Player if it is private Entity
@dekrain
@dekrain 7 жыл бұрын
Agent M yes, you can also write protected instead of public, then it will be visible in Player class, friend classes/functions and subclasses, but no outside
@Lmao-ke9lq
@Lmao-ke9lq 4 жыл бұрын
@@dekrain so inhariting with is going to be same as inheriting public, but with protected class member from inherited class?
@taocry
@taocry 4 жыл бұрын
After this video, something is missing. How to reuse the constructor from super class?
@anatolistankevich2592
@anatolistankevich2592 4 жыл бұрын
i've got the same question, dont know how to create an instance of my subclass, I've got a defined constructor in my superclass, but it doesnt work in subclass
@tannerbarcelos6880
@tannerbarcelos6880 5 жыл бұрын
My book and teacher are terrible. You have taught me what was making me second guess getting my cs degree lol. Stress has been slightly lessened! I still have an A in my c++ course but I’m starting to become a tad concerned on how all this operator overloading, inheritance and polymorphism is making me struggle..
@persistence2478
@persistence2478 7 жыл бұрын
Hey man! Love your videos! I have a question. Before you write your programs do you plan them out on paper? If so, can you share how exactly you do this and when do you know that you're ready to start writing code? If anyone else can share their method, please do. Thanks!!!
@eloquentlyemma
@eloquentlyemma 7 жыл бұрын
Persistence 24/7 I use DFDs (data flow diagrams - which designs the code around the data in the system - I think it's part of the JSD methodology if I remember correctly), process flow charts and pseudo code. I did learn UML for university - I didn't like it much, but it is the one to learn if you are looking for job skills.
@persistence2478
@persistence2478 7 жыл бұрын
thanks so much! I'll look into those methods!
@theNeuo13
@theNeuo13 2 жыл бұрын
thanks for your videos, there are really helpful. which one of them is talking about overriding a function?
@zerotoinfinity3189
@zerotoinfinity3189 3 ай бұрын
i am new to c++ can any explain what is meant by this statement i could not find answer to this online in example give in video class Player : public Entity::something ::something can anyone explain this what is meant by above state have seen similar in a code base trying to understand
@inwerp
@inwerp 7 жыл бұрын
Use ctrl + f5 to build-run and keep the console open.
@Indraneel-Ahluwalia
@Indraneel-Ahluwalia 6 жыл бұрын
Hi thanks for good videos . Please make a video on friend classes and functions.
@darimuhittin
@darimuhittin 8 ай бұрын
If you say 'Exactly' in a whole 10 hours video again and again i can watch it
@darimuhittin
@darimuhittin 8 ай бұрын
Im not gay.
@tessanix9771
@tessanix9771 Жыл бұрын
I Always see the line "priorise composition over inheritance". Can you explain this concept in c++ ?
@tcchan14
@tcchan14 5 жыл бұрын
interesting concept. Subclass actually contain more from superclass.
@ceachibogdan8087
@ceachibogdan8087 5 жыл бұрын
Hey, can you make some tutorials for parallel programming in c++ ?
@OneShot_cest_mieux
@OneShot_cest_mieux 5 жыл бұрын
It would be awesome
@christophilous4831
@christophilous4831 6 жыл бұрын
Why don't the functions PrintName and Move occupy any memory in the sizeof calculation? Wouldn't the object need to hold a pointer to them, at least?
@reubenfrench6288
@reubenfrench6288 7 жыл бұрын
How do static variables get inherited? Is there still just one copy for all instances of BaseClass and its subclasses, or is there a separate copy for each of its subclass types?
@1314520Joanna
@1314520Joanna 6 жыл бұрын
I tested the same code, somehow I get total of 16 bytes but not 12 like you presented in the video? Is it something wrong with my machine or setup?
@vertigo6982
@vertigo6982 6 жыл бұрын
size varies with machine and compiler.
@khaydiandennis1461
@khaydiandennis1461 5 жыл бұрын
Why did you use void move
@h.hristov
@h.hristov 7 жыл бұрын
Thanks! Love your videos man
@abdulcool1268
@abdulcool1268 6 жыл бұрын
hey one question. can we not have a function and a class of same name. for eg if we write void player(float xa,float ya) and we have a derived class player. if we create an obj and try to call the player function it shows an error
@thorep
@thorep 5 жыл бұрын
is the __declspec and stuff like that explained in the c++ series?
@botobeni
@botobeni 3 жыл бұрын
why char* occupies 4 bytes of memory, but can be a very lenghty string(more than 4 bytes)??
@walkmoon3479
@walkmoon3479 2 жыл бұрын
char* is the pointer pointing the first char of a string. Once we know the where the first is, we literally knows where my string is
@aamg9586
@aamg9586 Жыл бұрын
Why is the size of the player class 12? I understand that when the player class inherited the two floats x and y from the entity class so that's 8 but when adding char, isn't supposed to add only a 1 byte extra and the size becomes 9? Or is char* different from the one without the suffixed astrix "char"?
@awsumturtle
@awsumturtle Жыл бұрын
Because a const char* is a pointer, not a char. That variable stores a memory address that points to a location of where characters are stored or where a series of characters are stored. And just to add: a pointer is 4 bytes in a 32-bit application, dependent on the machine and compiler ofcourse!
@aamg9586
@aamg9586 Жыл бұрын
@@awsumturtle Thanks Buddy! Now it's much clearer to me that a pointer is a 4 byte worth of memory in a 32bit application. So that must be it, right?
@awsumturtle
@awsumturtle Жыл бұрын
@@aamg9586 No problem. And yes, that's how it is but like I said it all depends on the machine and compiler. In this example though, it is 4 bytes.
@aamg9586
@aamg9586 Жыл бұрын
@@awsumturtle much love xx
@DrGreenGiant
@DrGreenGiant 4 жыл бұрын
May I request a video on virtual inherence please?
@TKcKoucher
@TKcKoucher 2 жыл бұрын
Hey guys, hoping somene can help with a syntactic doubt here, english is not my native language so sometimes I struggle a bit.. In the example of the video, would it be correct to say that the functionality of Entity class is inherited to the Player class?
@santhoshjallu926
@santhoshjallu926 Жыл бұрын
yes, you can also say Player has inherited the entity class or vice versa
@DigitalDivotGolf
@DigitalDivotGolf 5 жыл бұрын
excellent job
@mmoa1985
@mmoa1985 7 жыл бұрын
So why is inheriting different than including? for example: if in this video we included the Entity class inside the Player class.. will this be the same or there are differences?
@reycors6871
@reycors6871 5 ай бұрын
thanks bro
@InFmou5
@InFmou5 4 жыл бұрын
Its sucks that classes inheritance in separate files was not handled here.... I'm having a lot of issues trying to figure out how to handle a class inheritance from a separate file and I'm getting a redefinition error that I have no idea why is happening.
@bobdagamer640
@bobdagamer640 Жыл бұрын
Do yoy have include guards on the headers?
@EtBukaneluu
@EtBukaneluu 3 жыл бұрын
could we just move printName to entity class ? and how its gonna look like ?
@can3792
@can3792 2 жыл бұрын
at the end of the video had me in laugh :D :D
@Scherbakov
@Scherbakov 2 жыл бұрын
Super! But sometimes the subtitles disappear somewhere.
@Braindrain85
@Braindrain85 7 жыл бұрын
Is it better to write the Player- and Entity class in the same cpp file (Entity) or would it be cleaner to make a new file for the Player class?
@lewisb8634
@lewisb8634 7 жыл бұрын
Braindrain85 No, not usually. There's nothing stopping you of course, it's all up to you, but classes are generally written in separate files. If the base only has one sub class and they are generally both modified at the same time, then having the two classes in the same file might be beneficial. But if there's only one sub class, then you should probably consider whether it's inheritance you should really be using! Short answer, no put them in different files :)
@蜜熊胖胖猪
@蜜熊胖胖猪 Жыл бұрын
I thought member function also takes some memory in a class....anyone could explain why size of only return member variables?
@bobdagamer640
@bobdagamer640 Жыл бұрын
Member functions are stored with the rest of the code, not with the instance of the claas. Sizeof only returns the size of the memory used by an instance of an object
@Djzaamir
@Djzaamir 7 жыл бұрын
can someone please answer me , why did he use const char instead of just char
@Steven-tw7iz
@Steven-tw7iz 7 жыл бұрын
the const keyword changes the variable to a "read only" state so you don't accidentally modify its value later on in the code and cause an unforeseen bug. Its generally considered good programming practice to make any variable that doesn't need to be modified in the code a 'const' variable.
@Djzaamir
@Djzaamir 7 жыл бұрын
i see , Ste_3 D_ven thanks for quick reply :)
@aVeryAngryDuck
@aVeryAngryDuck 4 жыл бұрын
Great video very helpful explanation 👍
@伟-p7p
@伟-p7p 5 ай бұрын
Your video is great, but there are no subtitles after 4.04 seconds, which is a bit difficult for people whose native language is not English. We hope you can solve this problem. Thank you 4:04
@伟-p7p
@伟-p7p 5 ай бұрын
I don't want to interrupt the progress of my studies
@heco.
@heco. 4 күн бұрын
you can really just turn on auto caption
@explorerofworlds512
@explorerofworlds512 4 жыл бұрын
whenever I type std::cout
@leocarvalho8051
@leocarvalho8051 4 жыл бұрын
beacause that is not char. thats a pointer, and a pointer is 4 bytes on 32 bit pc
@user-dh8oi2mk4f
@user-dh8oi2mk4f 3 жыл бұрын
The player doesn’t have a char variable, it has a char pointer.
@KillzoneKid
@KillzoneKid 7 жыл бұрын
Kinda expected to see explanation of types of inheritance (public, protected and private) as well as default inheritance. Little disappointed with this episode of otherwise excellent series.
@栗雪-m6m
@栗雪-m6m 5 жыл бұрын
Cherno has another video "Visibility in C++"
@rarasdfa12312
@rarasdfa12312 4 жыл бұрын
you are the best
@ghofranetorjmene2960
@ghofranetorjmene2960 Жыл бұрын
hello , the size of char is 1 byte ! so the size of const* char Name is equal to 1 byte and not 4 bytes !
@sleepyNovember_project
@sleepyNovember_project 7 ай бұрын
man
@am.PURPLE
@am.PURPLE Жыл бұрын
why my output is coming 16 even though I typed everything the same as the cherno did???
@johnpaulziifle6218
@johnpaulziifle6218 Жыл бұрын
I messed around with it because I had the same result. When typing std::cout
@wpxie2746
@wpxie2746 Жыл бұрын
@@johnpaulziifle6218 In C++, the size of a `char*` pointer is platform-dependent and can vary based on the architecture and compiler you're using. The size of a pointer, including `char*`, is determined by the underlying system's memory model and word size. On most modern systems: - **32-bit systems**: A `char*` pointer typically occupies 4 bytes (32 bits) of memory. - **64-bit systems**: A `char*` pointer usually occupies 8 bytes (64 bits) of memory. However, it's important to note that these are general trends and not strict rules. The actual size of pointers can vary based on compiler settings, operating systems, and other factors. To find out the specific size of a pointer on your system, you can use the `sizeof` operator: ```cpp #include int main() { std::cout
@ipizza9941
@ipizza9941 Жыл бұрын
I thought char was one byte. How is it 4 here?
@alexz3346
@alexz3346 Жыл бұрын
You are right the size of a char is one byte. However, he was talking about a pointer to a char. A pointer needs to hold the memory address to the thing it is pointing to. On a 32-bit system it takes 4 bytes to store that memory address.
@sgyffysgyffy4736
@sgyffysgyffy4736 6 жыл бұрын
Great video
@nikowill6979
@nikowill6979 7 жыл бұрын
great video, still need more in depth stuff...
@sebastianricks9459
@sebastianricks9459 4 жыл бұрын
Hello :). Love the videos. Thank you so much! Have you made one on polymorphism yet?
@banscheygrey7436
@banscheygrey7436 4 жыл бұрын
X , Y and all class members should be private ! It's a fundamental paradigm of oop. Many peoples which just started learn c++ will do a lot of mistakes in future after this video. And all of privates members should be protected if current class will be parent for others. it's extremely important.
@Raul11madrid1
@Raul11madrid1 7 жыл бұрын
Thank you .. 🌹🌹
@kushalvadher
@kushalvadher 9 ай бұрын
pls show altr for super key word in c++
@seatoaster1491
@seatoaster1491 7 жыл бұрын
Could you do a video on what a operating system kernel is
@primulaeinscode
@primulaeinscode Жыл бұрын
Tell your teacher this: "This is how you teach."
@pdxbound81
@pdxbound81 5 жыл бұрын
I'm only going to learn C++ if you promise my hair will look as cool as yours!
@johuremoker3818
@johuremoker3818 5 жыл бұрын
thanks a lot~
@TheZenytram
@TheZenytram 3 жыл бұрын
so it is basicaly the same concept of a function but for classes.
@VoidAshen
@VoidAshen 3 жыл бұрын
oh we aren't even scraping the surface *sees 27/95 oh yea we aren't
@edwinov
@edwinov 5 ай бұрын
Now your name is "Acherno" !?
@geertdepuydt2683
@geertdepuydt2683 7 жыл бұрын
And when you want an entity that can't move...?
@mintentha
@mintentha 7 жыл бұрын
I don't know for certain, but I assume you could overwrite it to not exist the same way that you can overwrite the constructor?
@QrchackOfficial
@QrchackOfficial 7 жыл бұрын
Override it or make EntityMoveable and EntityNotMoveable classes, or better yet - have a boolean called moveable in your Entity, add a canMove() method to your Entity that returns moveable and check against that in your Move() method - if canMove() is false, do nothing, or better yet - make your Move() method return a "illegal operation" result/exception
@livesimplyandhumbly
@livesimplyandhumbly 4 жыл бұрын
I subscribed because we share the same fashion statement.
@AbdulMoiz-ho8rx
@AbdulMoiz-ho8rx 2 жыл бұрын
Great
@abhisheksengupta4159
@abhisheksengupta4159 6 жыл бұрын
#include #include "shredder.h" class entity { public: int a, b; entity() { int a = 0; int b = 0; } void move(int ax, int by) { a = a + ax; b = b + by; } }; class player : public entity { public: void display() { print(a); print(b); } }; int main() { entity e; player p; p.move(10,10); p.display(); pause; return 0; } Why using constructor giving values of a and b other than 10 ? if a and b manually set to 0 it is giving correct answer...
@abhisheksengupta4159
@abhisheksengupta4159 6 жыл бұрын
@paterolen Many Thanks bro,i just missed it ... :D
Virtual Functions in C++
6:45
The Cherno
Рет қаралды 512 М.
Templates in C++
17:58
The Cherno
Рет қаралды 595 М.
Synyptas 4 | Арамызда бір сатқын бар ! | 4 Bolim
17:24
Officer Rabbit is so bad. He made Luffy deaf. #funny #supersiblings #comedy
00:18
Funny superhero siblings
Рет қаралды 19 МЛН
Smart Sigma Kid #funny #sigma
00:14
CRAZY GREAPA
Рет қаралды 7 МЛН
WHY did this C++ code FAIL?
38:10
The Cherno
Рет қаралды 264 М.
C++ vs Rust: which is faster?
21:15
fasterthanlime
Рет қаралды 398 М.
you will never ask about pointers again after watching this video
8:03
CONST in C++
12:54
The Cherno
Рет қаралды 406 М.
C++ Inheritance: constructors and destructors in base and derived classes  [3]
8:23
C++ OOP - What is inheritance in programming?
16:32
CodeBeauty
Рет қаралды 145 М.
POINTERS in C++
16:59
The Cherno
Рет қаралды 1 МЛН
The Wordpress drama keeps getting worse
12:47
Theo - t3․gg
Рет қаралды 98 М.
Dynamic Arrays in C++ (std::vector)
14:14
The Cherno
Рет қаралды 381 М.
Object Oriented Programming (OOP) in C++ Course
1:30:26
freeCodeCamp.org
Рет қаралды 2,5 МЛН
Synyptas 4 | Арамызда бір сатқын бар ! | 4 Bolim
17:24