No video

C++ Tutorial 10 : Object Oriented Programming

  Рет қаралды 240,776

Derek Banas

Derek Banas

6 жыл бұрын

Code & Transcript : bit.ly/plusplus10
Subscribe to Me: bit.ly/2FWQZTx
Best C++ Book : amzn.to/2JNlnk5
I'm finally covering Object Oriented Programming with C++! I cover classes, objects, public, private, protected, constructors, deconstructors, pointer operator, dot operator, getters, setters, super classes, inheritance, calling super class functions, overwriting functions, and much more.
In the problem with this tutorial we will try to model a battle between the Hulk and Thor to the death.
MY UDEMY COURSES ARE 87.5% OFF TIL January 31st ($9.99)
➡️ Python Data Science Series for $9.99 : Highest Rated & Largest Python Udemy Course + 56 Hrs + 200 Videos + Data Science bit.ly/Master_Python_45
➡️ C++ Programming Bootcamp Series for $9.99 : Over 23 Hrs + 53 Videos + Quizzes + Graded Assignments + New Videos Every Month bit.ly/C_Course_45
➡️ FREE 15 hour Golang Course!!! : bit.ly/go-tutorial6 (100 Available)
Like the channel? Consider becoming a Patreon! Check it out here:
►► / derekbanas
Watch More Learn in One Videos
►► Java - • Java Tutorial
►► C++ - • C++ Programming
►► Python - • Python Programming
►► MySQL - • MySQL Tutorial
►► PHP - • PHP Programming
►► Kotlin - • Kotlin Tutorial
►► C# - • C# Tutorial
►► JavaScript - • JavaScript Tutorial

Пікірлер: 304
@derekbanas
@derekbanas 5 жыл бұрын
Learn in One Videos for Every Programming Language Subscribe to Bookmark them: bit.ly/2FWQZTx C++ : kzbin.info/www/bejne/iKbFXn2pn7Kbjbs Python : kzbin.info/www/bejne/hGXQdq18ec-kqqM Java : kzbin.info/www/bejne/pF7bcqSZd6iqqZY PHP : kzbin.info/www/bejne/bYWpYWOef65qbrs MySQL : kzbin.info/www/bejne/r4HYZ6SMasesq5Y JavaScript : kzbin.info/www/bejne/nJvYapyfbb6mfdU C# : kzbin.info/www/bejne/oprWmqqLj6-Lp7M HTML5 : kzbin.info/www/bejne/oXXce4FtprZ4iqM CSS3 : kzbin.info/www/bejne/eYbbeZKojLh8Z80 JQuery : kzbin.info/www/bejne/eIi7mJp4YrlkoLM TypeScript : kzbin.info/www/bejne/Y4G1kIunjJ59gLc ECMAScript : kzbin.info/www/bejne/gJLOoJxmfJ2feMk Swift : kzbin.info/www/bejne/mnzEoJ2Fj5KUsJo R : kzbin.info/www/bejne/qWSpoK2Mm8lqp5Y Haskell : kzbin.info/www/bejne/ZmPCeWaCn9aAqJo Handlebars : kzbin.info/www/bejne/annYcqGDa8dlmpo Bootstrap : kzbin.info/www/bejne/naKydqKLh5qFfsk Rust : kzbin.info/www/bejne/i2Kod5p5g7F3eJo Matlab : kzbin.info/www/bejne/hIS2hZ6hgLeUmKs Arduino : kzbin.info/www/bejne/h4DCe5-wZtajetk Crystal : kzbin.info/www/bejne/eqmpgWCNn9anqcU Emacs : kzbin.info/www/bejne/f5LKk6lvbJl6orM Clojure : kzbin.info/www/bejne/mZqqqnuhedqDd6c Shell : kzbin.info/www/bejne/nqjVn6CHqtKnhtk Perl : kzbin.info/www/bejne/jXbKmXyOqJ15bMU Perl6 : kzbin.info/www/bejne/omHdgaqenLyHna8 Elixir : kzbin.info/www/bejne/pnOxgJSsh9SBgpI D : kzbin.info/www/bejne/qKi9d4ekm56Verc Fortran : kzbin.info/www/bejne/lZCVhpp8g76anJo LaTeX : kzbin.info/www/bejne/jJnQnH-ohM9_qdk F# : kzbin.info/www/bejne/mWjIf3eAg5xobrc Kotlin : kzbin.info/www/bejne/fpDSeJxuqtp3pqM Erlang : kzbin.info/www/bejne/f3bLqJZoppatfZY Groovy : kzbin.info/www/bejne/eGqbm5Zuncmob8k Scala : kzbin.info/www/bejne/equppWOPoL-ibq8 Lua : kzbin.info/www/bejne/n37ElKuQhrKDjtU Ruby : kzbin.info/www/bejne/epvManSCeMyZpq8 Go : kzbin.info/www/bejne/eXechGeHj9qJaZI Objective C : kzbin.info/www/bejne/a5bWgqSQfq9rack Prolog : kzbin.info/www/bejne/iarOqYqme9yAfdU LISP : kzbin.info/www/bejne/r562ometfdekr7c Express : kzbin.info/www/bejne/rnWmfJaEd6umq6s Jade : kzbin.info/www/bejne/omakiZaOdrVnqJo Sass : kzbin.info/www/bejne/rauWnHiigcd4fqc
@kanchabeni6743
@kanchabeni6743 4 жыл бұрын
so if u create animal object with no parameter, thede animalcount will still increment?
@auroric8231
@auroric8231 6 жыл бұрын
Without your videos my entire programming class would have failed horribly. A couple years ago when I was in junior year of high school I had to switch schools and went from some random tech related class to programming and our teacher knew absolutely nothing (She was a nice old lady that we all liked though and after graduation we found out she had early stages of alzheimer's). Anyway I walked into the class first day realized we were totally screwed so I cam home that night watched your C++ in one video thing and proceeded to be allowed to teach the class and got moved to AP programming (same teacher school has no budget). Basically what I'm getting at here is I wanted to say thank you for essentially saving our class and getting me into AP programming where I made some awesome friends. Side note friends of mine are in college for related subjects and I'm planning on going as well.
@derekbanas
@derekbanas 6 жыл бұрын
Thank you for taking the time to tell me such a nice story :) I greatly appreciate it! It has been my honor to be of help. I wish you all the best in life!
@auroric8231
@auroric8231 6 жыл бұрын
You are too humble.I just thought you should know that you were and are a great help to me, my friends, and many others trying to learn. You are definitely one of the best teachers I have the honor of learning from.
@derekbanas
@derekbanas 6 жыл бұрын
Thank you once again :) I'm very lucky to be able to do this and I'm lucky to have such a nice community of people who watch my videos.
@Awesomekid2283
@Awesomekid2283 6 жыл бұрын
Auroric Wolf Was your AP Programming course the same as my AP Computer Science course? I used his all-in-one-video Java course before I started that class and ended up passing with an A and a 5 on the AP exam. Derek Banas your ability to communicate any programming language is astounding and I thank you for each and every one of them. By the way, I don't want to make you reveal your secrets or anything, but how do you know literally every programming language there is? I'm assuming you could probably code in binary if you wanted to
@IndellableHatesHandles
@IndellableHatesHandles 4 жыл бұрын
Coming from C# and Python, the class syntax is probably one of the only things that trips me up.
@vil3n80
@vil3n80 3 жыл бұрын
Exactly!
@zuma3918
@zuma3918 5 жыл бұрын
You are the ONLY one on the internet who knows to explain c++ good. Not like some guys putting up tutorials just to show that they know. Thank you for making this, i learned c++ (and programming techniques) from you!
@derekbanas
@derekbanas 5 жыл бұрын
Thank you for the nice compliment :) I appreciate it!
@TravelingMooseMedia
@TravelingMooseMedia 4 жыл бұрын
I started this video and ended up creating a full on GAME that has a list of ninjas to choose from and create yourself with health and attack values, ninja levels, moves to choose from, experience points to level up, and all sorts of implementations! Thank you for your tutorials and inspiration
@derekbanas
@derekbanas 4 жыл бұрын
That's awesome! I'm happy you had fun with it
@wifiextender2
@wifiextender2 Жыл бұрын
Instead using C srand/om you can use the STL one - std::random_device rd; std::uniform_int_distribution udist(0, 26); , will give us a random number in the range of 0 to 26
@riachomolhado999
@riachomolhado999 6 жыл бұрын
Believe. We use their video to teach object-oriented programming to needy young people in Brazil. Thank you very much.
@derekbanas
@derekbanas 6 жыл бұрын
That is so very nice to hear :) I'm amazed people all over the world are benefiting from my videos!
@anthony452
@anthony452 4 жыл бұрын
Always my go-to source when I need new info. Finishing a C++ class but I've been doing tons of JS learning and needed to see a quick video on C++ classes. These videos are always quick and to the point, no filler or lag from errors. I really appreciate the work!
@derekbanas
@derekbanas 4 жыл бұрын
Thank you for the nice compliment :) I greatly appreciate it!!!
@sirrealistically
@sirrealistically 2 жыл бұрын
24:58 ; it’s fantastic! I felt the neatness. Even knowing OOP, I loved watching this master piece
@vil3n80
@vil3n80 3 жыл бұрын
the first 5min helped me understand classes so much more than the 3hour lab my professor taught
@shkhamd
@shkhamd 5 жыл бұрын
Note at 15.35 : Since all the objects are allocated on the stack, Tom object is destroyed before Fred.
@Krishna-ff3by
@Krishna-ff3by 3 жыл бұрын
tnx
@RussTeeTrombone
@RussTeeTrombone 6 жыл бұрын
Derek, your videos are fantastic and have effectively replaced the mediocre instruction I'm unfortunately paying for at a local college. Your chosen examples are illustrative, to the point, and quite enjoyable. Thanks for your contributions.
@NicoScholz90
@NicoScholz90 5 жыл бұрын
You can initialize the member variables in the creator also in this way: class Warrior { private: std::string m_name; int m_health, m_attack, m_block; bool m_bAlive; public: // Creator Warrior(std::string t_name, int t_health, int t_attack, int t_block) : m_name(t_name), m_health(t_health), m_attack(t_attack), m_block(t_block), m_bAlive(t_health) { // that way you dont need to set variables in the constructor body as everything gets initialized on creation } }; I think this works since C++11 if i am not mistaken. :)
@stefanoangeli3636
@stefanoangeli3636 4 жыл бұрын
Hi Derek! I'm spending my time on your channell to get knowledge on C++ for my project. You're definetely amazing! I'm a beginnner of C++, and I'have never learnt C++ in my life! Thank you very much!
@derekbanas
@derekbanas 4 жыл бұрын
Thank you very much :) It is very nice to hear that I'm helping
@sanketjain8366
@sanketjain8366 4 жыл бұрын
Thank you so much :) This was the best explanation of classes in C++ I've ever seen
@derekbanas
@derekbanas 4 жыл бұрын
Thank you very much :)
@nifets
@nifets 6 жыл бұрын
Thanks for these tutorials! This battle simulation thingy was really fun to make and, since I'm a complete newbie when it comes to OOP, it helped a lot with understanding the main concepts. Continue the good work!
@nifets
@nifets 6 жыл бұрын
Also, this is my take on the problem: (with some personal touches) #include #include #include class Warrior { private: std::string name; double hp; double atk_dmg; double dodge_chance; public: std::string GetName() {return name;} void SetName(std::string name) {this -> name = name;} double GetHp() {return hp;} void SetHp(double hp){this->hp = hp;} double GetAtkDmg() {return atk_dmg;} void SetAtkDmg(double atk_dmg){this->atk_dmg = atk_dmg;} double GetDodgeChance() {return dodge_chance;} void SetDodgeChance(double dodge_chance) {this->dodge_chance = dodge_chance;} double Attack() { int value = this->atk_dmg * 100; return double(std::rand() % value + (value/2))/100; } bool Dodge() { int value = std::rand() % 10000; double v = double(value); v = v / 100; if (v > this->dodge_chance) return 0; else return 1; } void SetAll(std::string, double, double, double); Warrior(std::string, double, double, double); Warrior(); }; void Warrior::SetAll(std::string name, double hp, double atk_dmg, double dodge_chance) { Warrior::SetName(name); Warrior::SetHp(hp); Warrior::SetAtkDmg(atk_dmg); Warrior::SetDodgeChance(dodge_chance); } Warrior::Warrior(std::string name, double hp, double atk_dmg, double dodge_chance) { Warrior::SetAll(name, hp, atk_dmg, dodge_chance); } class Battle { public: static void StartFight(Warrior& a, Warrior& b) { int value = std::rand() % 2; bool l = bool(value); bool p = 0; while (p != 1) { if (l == 0) p = AttackResult(a, b); else p = AttackResult(b, a); l = 1 - l; } } static bool AttackResult(Warrior& a, Warrior& b) { double a_attack = a.Attack(); bool b_dodge = b.Dodge(); double b_hp = b.GetHp(); std::string a_name = a.GetName(); std::string b_name = b.GetName(); if (b_dodge) { std::cout
@derekbanas
@derekbanas 6 жыл бұрын
Thank you for sharing :) I'm happy you liked the tutorial
@postfixnotation9829
@postfixnotation9829 6 жыл бұрын
Your channel is a pure treasure. Thank you! 1) A video series about building apps with Native React would be a nice! 2) Add a PayPal Link so that people can support you without subscribing to Patreon!
@derekbanas
@derekbanas 6 жыл бұрын
Thank you very much :)I'll see what I can do about React. If people just turn off AdBlocker during my 5 second ads that is all I ask.
@1smarter2gus
@1smarter2gus 6 жыл бұрын
Great tutorial, really enjoyed it. Got refreshed on some stuff and learned new stuff.
@derekbanas
@derekbanas 6 жыл бұрын
That's great! I'm happy you enjoyed it
@Awesomekid2283
@Awesomekid2283 6 жыл бұрын
Hello again. I just wanted to mention a few things that I noticed; forgive me if I mention something that you cover in a later video. Just by looking at the titles I don't know if you will end up covering any of this, so I'm mentioning it here. I'm just going to briefly explain here what the concepts are as I think you should go over them in more detail in a dedicated video as they are important topics as they pertain specifically to C++; I think you are certainly more qualified to be explaining and teaching these concepts and you do such a wonderful job as it is. In addition, please correct any mistakes I may make here so that other people reading this comment won't get false information: I want to first start off by declaring some terminology so new coders know what I'm talking about below: - When inheriting, the class doing the inheriting is called the subclass, the child class, or the derived class and the class being inherited from is called the base class or the parent class - When inheriting, a concept that comes up is the idea of 'is-a/is-an' vs. 'has-a/has-an', which refers to whether an object is-a/is-an of another object or whether an object has-a/has-an of another object. For instance: a square is-a shape, which means that anywhere a shape is needed, a square can fill in (this comes into play when polymorphism is talked about which he does have a video on), but a car has-an engine, which means that you cannot use an engine anywhere a car is required, but the car still has an engine and can use it's functionality. Another way that is commonly used to think about has-a/has-an is to say blank _implements_ blank. That way of thinking is usually used when talking about abstract classes which can serve as C++ versions of interfaces (a part of the Java programming language) which I will explain a little below 1. Public vs. Protected vs. Private inheritance: You may have been wondering why C++ required the 'public' keyword when inheriting. This is because 'public' is not the only type of inheritance. 'Private' and 'protected inheritance also exists! However, in about 95% of all inheritance cases, the inheritance is usually public, so you cannot go wrong with inheriting through public inheritance (public is the "normal" inheritance). I am by no means someone who should be explaining this as I have never used anything but public inheritance and I will probably end up making it sound really complicated (this is a complicated topic for all you new coders out there), but, on the surface level, it comes down to how you want public/protected/private members to be inherited: - if you inherit through public inheritance: public members remain public, protected members remain protected, private members remain private, and the members of the base class become members of the subclass and also members of the outside world (anything that is public can be seen by anyone and anything) - if you inherit through protected inheritance: public members are converted to protected members in the subclass (they remain public in the base class), protected members remain protected, private members remain private, and the members of the base class become members of the subclass, but not members of the outside world except for other inheriting classes since the subclass has no public members. Any class that now inherits from our subclass can only (at most) get protected and private members, and the rules for inheritance of protected and private members applies as it normally would - if you inherit through private inheritance: public members are converted to private members in the subclass (they remain public in the base class), protected members are converted to private members (they remain protected in the base class), private members remain private, and the members of the base class become members of the subclass and only the subclass as our subclass only has private members. One cannot inherit from this subclass (or rather it's pointless to inherit from the subclass) because they would only inherit private members, which our inheriting class cannot use, which means our inheriting class gets nothing from the inheritance. Protected and Private inheritance also have reasons for their usage, but I am not very familiar with them. Therefore, my recommendation is that if you need inheritance, you use public inheritance, since the only times when non-public inheritance has an advantage are very obscure cases and not likely to come up if you are a new coder 2. Multiple inheritance: Let's say that you have a shape class and a polygon class. Let's say you now have a square class. Obviously both the polygon class and the square class are going to be inheriting from the shape class because both polygons and squares are shapes, but that doesn't really describe the whole story. You want squares to be accepted both when shapes or polygons are required (polymorphism), and that can be achieved if you inherit from the polygon class (as a square is now a polygon which is a shape), but not if you inherit from shape (since a square is a shape, but not a polygon). In this case, you want a square to inherit both from the shape class and the polygon class (and potentially other classes too if you have more that fit this case, such as a four-sided shape class or something similar), and that is done syntactically exactly the way you think it's done: class Shape {}; class Polygon : public Shape {}; class Square : public Shape, public Polygon {}; The two classes that you're inheriting from both need their inheritance types specified (public/private/protected), which also means you can inherit differently depending on what you need. In this case, a square is-a shape and is-a polygon, so public inheritance is used (again, it's rare to see private or protected inheritance). Now our square class has access to the private and protected members of our shape class and our polygon class, and the compiler figures out how to handle the fact that square is technically inheriting twice from our shape class as both the polygon class and the square class inherit directly from our shape class. 3. Friend classes: Sometimes you will see in a class's public section something like this: class MyClass {}; class MyOtherClass { public: friend class MyClass; }; In the above example, this declaration of MyClass to be a friend of MyOtherClass means that MyClass can now access any hidden members of MyOtherClass (i.e. private and protected members). This also applies to objects of MyOtherClass (e.g. private member variables of MyOtherClass objects can be accessed like public ones, etc.). This is most useful in cases where you want members of one class to be private or protected, you're not inheriting, and you don't want any manipulative functions to exist (such as getters, setters, etc.), but you need access to the private members. Let's say there's a function in MyClass which takes an object of MyOtherClass, since MyClass was declared a friend, this MyOtherClass object taken by the function in MyClass can have all of it's members accessed. I've used this in my data structures class and it is useful even if it may sound weird or pointless without a specific example (I cannot think of one right now). 4. Class qualifiers: Another thing you're probably going to see quite frequently are const class member function qualifiers. When you're working in a class, all member functions can be labeled with the 'const' qualifier, and virtual functions, which I talk about next, can be labeled with the 'override' and 'final' qualifiers. You'll learn what those are in the next section. The 'const' qualifier looks like this: class MyClass { public: void myFunc() const; }; void MyClass::myFunc() const { return; } Oh, that's another thing. In C++, you can return in void functions to end the function the same way a return statement would in a non-void function, but since the function is void, we just write 'return;' and don't return a value. It's really weird to work with until you get used to it. Anyway, back to the main topic. I have written the function prototype in the class and written the function definition below, and you can see how the 'const' qualifier is used in both cases (the 'override' and 'final' virtual function qualifiers would go in the same place). This 'const' qualifier serves to label functions which don't change the state of an object of the class. What this means is that you can label any function 'const' as long as it doesn't change anything, which usually applies to member variables. I was able to label the function above 'const' since all it does is exit, but functions like setters cannot be labeled 'const' since they change member variables. This will probably also be confusing without seeing it in one of Derek's videos, so I hope he does make one or mention it at some point, but most IDEs (the coding application) will tell you if you aren't allowed to use it, so feel free try it out. The reason you want to use this qualifier is as a check and a code simplifier. Labeling things 'const' doesn't affect whether or not the code can actually write to a memory location or not, but it prevents other people or yourself from breaking code that ordinarily would work fine. 'Const' helps with the maintainability of your code, and you use it for the exact same reason as you would label a reference parameter 'const'. This is the same thing, except it's for member functions to make sure they don't edit things if they shouldn't be editing as well as allowing your IDE to point out problems with your code not adhering to your 'const' qualifiers and your compiler to make a compile-time complaint. In addition, if you have a const reference to an instance of your class or a constant instance of your class, your IDE or compiler will complain that the function you're trying to use is not marked 'const', so it only serves as a check for you. Continued in reply:
@Awesomekid2283
@Awesomekid2283 6 жыл бұрын
5. Virtual functions: In the animal class example in the video, he talked about overriding the function toString() in an inheriting subclass by simply declaring the function again and having it do something else. This, however, is only one way to achieve this, and which method you choose depends on the kind of behavior you want your code to exhibit. These two methods both exhibit the exact same behavior when you are dealing with definite objects (i.e. the objects themselves and not pointers to objects). I'm going to write some main code to illustrate my point: class Animal { public: void output() const { std::cout
@Awesomekid2283
@Awesomekid2283 6 жыл бұрын
I wanted to make a correction to my shapes example. The compiler will actually complain if you multiply inherit the way that I did because of the fact that Square already inherits from the Shape class if you have Square inherit from the Polygon class, as the Polygon class inherits from the Shape class. The compiler won't like you trying to inherit from the Shape class twice. I did have an assignment like this, however, using the shapes example and multiple inheritance, so you really want to use it when there isn't a direct inheritance from one class to another when there should be one. An example would be having an IsoscelesRightTriangle inherit from both the IsoscelesTriangle and the RightTriangle classes because it is both and that inheritance doesn't naturally follow from only inheriting one or the other. The compiler will be okay with the fact that both IsoscelesTriangle and RightTriangle both inherit from the same class if you have both of those classes inherit virtually from the same class, meaning they both inherit from my Triangle class and they both inherit like this: class IsoscelesTriangle : virtual public Triangle {}; But this is a really complicated example and new programmers won't have to worry about it. Another thing is that sometimes an error will come up that says a function is not polymorphic. This just means that you have to have at least one virtual function in that class to make it a polymorphic class, which even I don't completely understand, so maybe Derek can explain it in a new video or maybe he explains it in his polymorphism video
@derekbanas
@derekbanas 6 жыл бұрын
Wow!!! Thank you for taking the time to write down such useful information! I greatly appreciate it :)
@Awesomekid2283
@Awesomekid2283 6 жыл бұрын
Derek Banas It would really be great if you could do a video or videos on these topics since I probably don't completely understand them. I don't know if you were planning on making more C++ videos, but I would sure appreciate a few more!
@haohuynhnhat3881
@haohuynhnhat3881 4 жыл бұрын
what a long comment!
@Mycrosss
@Mycrosss 6 жыл бұрын
Another gem, I remember making a D&D type game in C where it would work in a very similar way as your Battle function does, except I messed around with some customization (you could choose your race,class,distribute some attribute points, level up, go to a shop, etc). Fun times, and Id definetely say that making people solve this type of problem is going to inspire them to implement more features and mess around on their own, whereas most of the lectures from my classes boring math problem solving when introducing OOP. Great job yet again :)
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) I'm very happy that you liked it. I need more examples like this
@emanuelkokovics
@emanuelkokovics 5 жыл бұрын
I love your tutorials, you explain very well. For the moment I am following this one, some of the C tutorials and the Java tutorial. But I will follow also the Python and others of your tutorial. :D
@derekbanas
@derekbanas 5 жыл бұрын
Thank you very much :)
@yanyangvictorli8786
@yanyangvictorli8786 5 жыл бұрын
Thank you for this great video. I was wondering how overwriting toString with inheritance worked with and without "virtual". It seems that you can overwrite a base class method from a derived class without the virtual method. Why do we need to use the "virtual"? Thanks again!
@2271masoud
@2271masoud 6 жыл бұрын
Thanks for this tutorial Derek. it's awesome. still got 30 more minutes to watch but I thought it's better to pause the video and thank you before I finish it all. Thanks again
@derekbanas
@derekbanas 6 жыл бұрын
Thank you for taking the time to say thanks :) I appreciate it. Get ready for that very hard problem at the end.
@2271masoud
@2271masoud 6 жыл бұрын
Derek Banas reminded me of this video in your C# tutorial series. The best way of teaching OOP. kzbin.info/www/bejne/mpbGl6CgbMdojMk
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) I'm using all my best things from numerous tutorials in this one
@luis622
@luis622 6 жыл бұрын
Thank you very much for all of these great videos! I have a slew of things that I'm interested in learning more about. As you progress can you make videos on binary files, threads, processes, pipes, and sockets? Not sure if it's outside of this series.
@derekbanas
@derekbanas 6 жыл бұрын
Yes I cover most of those in the series
@liquidmetal718
@liquidmetal718 5 жыл бұрын
Hi, we can have a isDead(), updateHealth(), updateAttack(), updateShield() for Warrior class. Also void A_attacks_B(Warrior* A, Warrior* B) and declareVictory() in class Battle. And make class Battle as friend of class Warrior. Doubt= How can a private function of a Class access a specific private variable of another Class, without using get Methods of that variable ?
@oneinabillion654
@oneinabillion654 3 жыл бұрын
Absolutely most brilliant intro to the essence of classes and objects
@derekbanas
@derekbanas 3 жыл бұрын
Thank you very much :)
@tronictl
@tronictl 6 жыл бұрын
Hi, Derek great tutorial as always. Three questions: 1. With this series are you going to cover polymorphism, virtual functions, linking and the cpp compiler? 2. Any chance you would do a learn hadoop in one video?
@derekbanas
@derekbanas 6 жыл бұрын
Yes to all the C++ topics. At the time I don't have a setup for Hadoop. I'll see what I can do in the future
@ToniVarga
@ToniVarga 6 жыл бұрын
great video, thank you very much!!
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) I'm glad you liked it
@rodramos5618
@rodramos5618 4 жыл бұрын
this interesting and very informative... i am new to your channel and c++ newbie, i want to establish my own game in the future if all is set... thanks man...
@derekbanas
@derekbanas 4 жыл бұрын
Thank you :) Happy I could help
@maxim25o2
@maxim25o2 3 жыл бұрын
This is almost exactly for what I was looking for. I hate using pointers and I am doing everything without pointers, but Your solution is so simple, And I understand why You use pointer for this special case. And i will love to use this in Codingame, Because now I have hard time to figure out how use two classes in side 3 class to menage that previous two classes. Before I was thinking about inheritance, but this method create new objects, in side of main class, but in my program i create Objects outside of main class and that's give me that problem of management
@filmsconan421
@filmsconan421 3 жыл бұрын
When I run the first code, it said"ISO c++ forbids initialization of a static member.", So what do I do?
@syednoorakbar9094
@syednoorakbar9094 4 жыл бұрын
Hello Sir I want to know about that When a temporary object is made by compiler a copy constructer runs how????
@PhotoBoothMaestro
@PhotoBoothMaestro 3 жыл бұрын
Hello Derek, First of all, I want to THANK YOU a lot for your lessons, they are great, but I have a question regarding the SetAll function from 9:18... What is the purpose of this function? because you didn't use it anywhere... Thank you!
@blackscorpion5409
@blackscorpion5409 4 жыл бұрын
i love your videos.Thank You for making these videos........... love
@derekbanas
@derekbanas 4 жыл бұрын
Thank you very much :)
@gokusaiyan1128
@gokusaiyan1128 6 жыл бұрын
Hey Derek, don't forget to cover STL tutorials too please. Many few people actually covers STL in details like maps, sets, unodered_maps etc and when to use which data structure
@derekbanas
@derekbanas 6 жыл бұрын
I most definitely will
@ISawIt123
@ISawIt123 5 жыл бұрын
Maybe im wrong but in lines 49&50 you used warriorA for both variables, therefore isnt your warrior2damageb being calculated as if warriora is attacking himself while still the damage to himself is still be distributed to warriorb?
@jonathany1240
@jonathany1240 2 жыл бұрын
I had an error where the fight would go on forever and it turns out that it was because I added newline “/n” to the end of the 2 final return statements in GetAttackResult. I never really questioned what the return statement did but this was interesting that it has some sort of break built in that (seemingly?) doesn’t happen when you add /n
@kidbuu1328
@kidbuu1328 3 жыл бұрын
Dude that went by so fast but it made it all click for me suddenly- thanks.
@derekbanas
@derekbanas 3 жыл бұрын
Thank you :) I'm happy you found it useful
@hehateme3712
@hehateme3712 4 жыл бұрын
I’m a bit confused. For the battle, how does the text from GetFightResult get outputted to the window when you execute StartFight? Because from what I see, StartFight does not have a line that outputs GetAttackResult
@FritsvanDoorn
@FritsvanDoorn 6 жыл бұрын
Hi Derek, I remember this one from your Java course. I find it unfair that warrior 1 always starts fighting so I made a random number to decide who starts. Fun. I was reading comments from others and thought: Hmm, I believe I follow your videos for about 8 years now? Give or take? I started following you with the series about Design Patterns which I never ever needed to use unfortunately. I followed most of you videos but didnot always commented. And the videos about programming I usually watch them now and then to keep rembering your solutions. At first it was difficult for me to understand your English because you have some accent I did not know, but now I am used to it and have no problem in following you. And if you ask me what the accent is, well I do not hear it now anymore. I am looking forward for you next piece of art. Thank you very much in advance!!
@derekbanas
@derekbanas 6 жыл бұрын
I'm glad you enjoyed it. I was going to add random weapons, armor, etc. Thor with and without his hammer, but the video was getting very long. Yes I remember seeing your picture a lot over the years. Thank you for watching. I don't make videos that are that relaxing to watch. I'm from Pittsburgh, PA if you are interested in the accent.
@davidyos2575
@davidyos2575 5 жыл бұрын
Just a simple note if you're familiar with C++, The property or method in Class in C++ are in private by default so you don't really need to add private: keyword, add public: for the property or method you want to be public instead. And also, you can add a line "using namespace std;" below your library to simplify your code without the need of typing std:: everytime. For example : std::cout
@gnitsaf
@gnitsaf 5 жыл бұрын
There are a number of reasons to not use using namespace. For me, it makes my code more readable. But it's personal preference.
@ahmedbichmou8073
@ahmedbichmou8073 4 жыл бұрын
Very cool !! thanks
@derekbanas
@derekbanas 4 жыл бұрын
Thank you :)
@statusforall8249
@statusforall8249 6 жыл бұрын
sir you are awesome
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) I try to do my best
@ahmedzaghloul9425
@ahmedzaghloul9425 6 жыл бұрын
Hi Derek Thanks a lot . This course is awesome and you are so genius man. In class animal I think we shouldn't increment NoOfAnimals in SetAll Function. we should do just in constructors. what do you think?? If we Run this main int main() { Animal Fred; Fred.SetAll("Fred", 10, 10); cout
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) Yes there is no need to increment in SetAll. Sorry for the mistake
@JacoboCordova
@JacoboCordova 4 жыл бұрын
And in the de constructor it could be decremented
@thejibtorres312
@thejibtorres312 4 жыл бұрын
Hello Sir.. Very helpful and informative video.I have a question that may have been asked already but since i can't find it in the comments, i would just ask it here. I made a deconstructor like you did here but my animal doesn't get destroyed like yours.. I didn't see you trigger it anywhere in the main() thank you really much to you sir.
@gregoryfenn1462
@gregoryfenn1462 5 жыл бұрын
For streaming to cout, why do you use '
@finnbuhse4775
@finnbuhse4775 5 жыл бұрын
im fairly new to c++ but in my testing you can put the constructors, deconstructors etc inside the class rather than defining them outside of the class, to me this makes more sense, any reason not to?
@Agersi420
@Agersi420 6 жыл бұрын
Love your vids Derek, any chance you make a Xamarin Forms tut in the future?
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) Yes I definitely want to. I'll see what I can do after C++
@Agersi420
@Agersi420 6 жыл бұрын
Sounds great, cant wait, thanks for the answer. Some Arduino oriented C++ would be awesome as well
@earthwombat
@earthwombat 6 жыл бұрын
Is the reason why you write out the methods for SetName, SetHeight, and SetWeight in the class is because they're short? It's the same as writing them outside the class right?
@Wildcat2236
@Wildcat2236 4 жыл бұрын
Not sure if you still check this, but I am very new to OOP in C++ and have been struggling with the concepts from your first example with the animal class. Can you explain how to accept user inputs for all of the animal attributes in the SetHeight and SetWeight methods? In the video you input the values yourself but what if we want the user to input them? How does that change the code?
@cl3375
@cl3375 6 жыл бұрын
Im going from java to C++ but I also know C, so I skipped ahead to here. I was beginning to feel like, 'Ok, I guess I already know C++'.. but I am still watching because I am learning things [ that have been explained to me SO many times ] in a new way! Man you explain it as it is. I already have 3 programs I am about to go revise and I am only 9 minutes in lol. ( I do kattis/code chef type problems for fun ) THANK YOU
@derekbanas
@derekbanas 6 жыл бұрын
I'm happy the tutorials have been useful :) I'll keep getting more and more complex
@bogdananton5257
@bogdananton5257 5 жыл бұрын
Hello, i have a question, when i am trying to write the destructor i get this error message "no operator "
@robxnguyen
@robxnguyen 6 жыл бұрын
At 32:32 when you make the statement - > static void StartFight(Warrior& warrior1, Warrior& warrior2). Is this what is called when the class is called in the main function? Such that Thor = warrior1 and Hulk = warrior2 ?
@derekbanas
@derekbanas 6 жыл бұрын
Yes I'm calling the function and passing in the 2 warriors that battle to the death
@bluepi7195
@bluepi7195 6 жыл бұрын
Love these C++ tutorials! Is there any case when C++ is an objectively better language to use over some other language like Java?
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) Yes when you have to program on the hardware level C++ rules. I'll get into Arduino soon to show some examples. C++ is also great for games through the use of UE4
@MrSpecialR
@MrSpecialR 6 жыл бұрын
C++ is amazing at things that require maximum performance, be it hardware restrictions or gaining maximum performance. It's probably one of the best languages to learn programming concepts from, as it's low level enough for you to tinker with the internals, but still high enough to actually make something useful. Things like memory management and some other important things are done automatically in languages like Java. Games are a good example, Arduino projects, or heavily performance dependant projects. (and of course learning but that's not a scenario for a project)
@SenorQuichotte
@SenorQuichotte 6 жыл бұрын
I like C for low level drivers.
@austen3466
@austen3466 6 жыл бұрын
Hi I'm a beginner C++ learner and I've been finding a lot of these videos really helpful, especially this one because the object oriented part of C++ has been giving me a TON of trouble. So far I've been slowly going along with this video and things are making so much more sense now. That being said, I do have a few questions that I was hoping you'd be able to answer: 1. Is there a reason that you include those particular files at the beginning of your code? 2. Can you explain the difference between "private" and "protected?" I don't quite understand that. 3. I don't know if I'm fully understanding the usage of the "this" operator. For example, if I say "cout name," would it mean that I am trying to print the name variable for the object chosen? 4. Are destructors(deconstructors?) really necessary? Or are they just used to save storage space? Also the destroying seems to be an automatic process, is this true? 5. I was just hoping you could confirm if my understanding on constructors is correct: "A constructor with parameters will take those parameters and use them to assign values to the attributes/variables of the object being created. A default constructor has no parameters and the attributes of the object are automatically assigned and can then be assigned manually afterward using the public functions of the class. Static variables are the same for objects of the same class." Is this all correct? Sorry if I asked too many questions. Answers to any of these would really help. Thank you in advance since you don't get notifications for replies to comments or something. (I'll probably have more questions later as well :))
@derekbanas
@derekbanas 6 жыл бұрын
Always feel free to ask questions. I'm here to help :) 1. The libraries after #include provide premade functions that I use in the code that follows 2. Something marked as private won't be available to subclasses that inherit from the class where the private variable was created. Protected variables will be available to subclasses 3. When we create a class we don't know the name for the object. This is used in the class to refer to the object 4. C++ now utilizes default destructors so in most situations now you don't need to define them 5. Yes you are correct
@__marceloandres
@__marceloandres 6 жыл бұрын
Hey Derek, why I get number of animals = 4 instead of 3, I already tried copying and pasting your code to see if I made a mistake but it wasn't the case
@valeryanngo9283
@valeryanngo9283 5 жыл бұрын
Why this statement "int Animal::numOfAnimals = 0;" can assign 0 to private variable numOfAnimals outside of class?
@NicoScholz90
@NicoScholz90 5 жыл бұрын
This statement is an initialisation of the variable. Inside the class declaration it is only declared and not initialised. This is not to be mistaken with trying to access the variable from outside the class. You can only do this initialisation once. You are still not able to access the value from outside. Try this example: #include class Test { private: static int numOfAnimals; // variable is only declared here and not initialised public: static int getNumOfAnimals() { return numOfAnimals; } }; int Test::numOfAnimals = 7; // variable is initialised int main() { std::cout
@clbgrmn
@clbgrmn 6 жыл бұрын
At 9:00, why do you need to specify 'int' Animal::numOfAnimals = 0 rather than just Animal::numOfAnimals = 0? Shouldn't the compiler already know that it's an int? As it's written, it looks like a re-declaration or redefinition of the static.
@socdfx
@socdfx 6 жыл бұрын
at ~15:30 why is the destructor called when you execute the fred.ToString()? its not clear since the destructor is a separate method and its not called form the ToString method?
@derekbanas
@derekbanas 6 жыл бұрын
I believe it is always handled where the last object created is destroyed first as long as both are of the same object type
@mouadkerdoud9428
@mouadkerdoud9428 5 жыл бұрын
Hello everyone, Could someone explain to me why the Animal class's Destructor was applied to the Dog class even if he did not manually inherited it, like he did with the Constructor?! Do child classes inherit parent's Destructors? and not Constructors or what?
@mahakileach9223
@mahakileach9223 5 жыл бұрын
two fighters and *fight tooo the death*
@HARSHITKUMAR-wj4ex
@HARSHITKUMAR-wj4ex 4 жыл бұрын
i have a question?? Why don't u use namespace std for c++, you can prevent from using :: (scope resolution) multiple times...
@lovinraghava3550
@lovinraghava3550 4 жыл бұрын
It's not good programming practice in general.
@kunstkritik
@kunstkritik 6 жыл бұрын
34:00 is there really a difference by using ceil() here? All the values used before are integer already as Warrior::Attack() and Warrior::Block() return integers themselves.
@derekbanas
@derekbanas 6 жыл бұрын
No it isn't required. I wrote a lot of this code out of my head and forgot for a moment that I wasn't using doubles
@reversebros1510
@reversebros1510 5 жыл бұрын
Whats the program you are using called. How did you managed to install the black theme.. If you are using codeblocks @Derek Banas
@derekbanas
@derekbanas 5 жыл бұрын
NetBeans I show how to set it up here kzbin.info/www/bejne/epLQpnhuibJmrtE
@fazliddinatakhanov3113
@fazliddinatakhanov3113 4 жыл бұрын
Thank you
@derekbanas
@derekbanas 4 жыл бұрын
Happy to help :)
@bruhmode283
@bruhmode283 4 жыл бұрын
How do you know what to use when you want to program something? I've watched several videos of several people even have course on udemy and my biggest problem is knowing what to use. I know for loops while loops do while loops and functions and classes and variables ints doubles strings char pointers if else statements. I dont know what to put in the functions and classes and trying to figure what I need to put into those functions. I'm trying to learn how to make Ai and neural networks, video games Triple A quality and software that uses API for making decisions and executing actions based off the api data. And more but that's the basic.
@derekbanas
@derekbanas 4 жыл бұрын
Object Oriented Design is the answer to your question. This course will explain everything in Java but you should have no problem translating it into C++ kzbin.info/www/bejne/nHu6Z2iNpJx8fqs
@ne12bot94
@ne12bot94 4 жыл бұрын
I notice your not using + or //,Whats point of using for // + ' ' +\\ then?do i really need to add + at each end?
@EmpyrealDepth
@EmpyrealDepth 5 жыл бұрын
If I have using namespace std; with my header files would i need to use -> when using GetName() ?
@arissaizzati912
@arissaizzati912 5 жыл бұрын
Yes because this-> is actually a this pointer
@kajkcuzt9509
@kajkcuzt9509 3 жыл бұрын
very good video but I don't understand why you don't use "using namespace std"
@P170101
@P170101 4 жыл бұрын
How did you get C on your Mac?
@sirturnables
@sirturnables 5 жыл бұрын
Quick question Derek! I was thinking of developing some software with python compiled into a standalone executable. I searched around and I found Py2exe, Pyinstaller etc; but someone told me Python was not made for that, so that may cause unexpected problems for my software (An Accounting software for a shop). So I decided to use C++. Please tell me, could I have used Python? If yes, how best!!!
@sirturnables
@sirturnables 5 жыл бұрын
What has that got to do with my query? I already know python, but now learning C++ because I wanna compile. I wanna know if it is possible to compile Python code. And u are saying what...?
@emanuelkokovics
@emanuelkokovics 5 жыл бұрын
I get this cannot call member function int Animal::GetNumOfAnimals() without object error when I try std::cout
@nixlq
@nixlq 5 жыл бұрын
where you destroy the animal( in ~Animal)
@Twysthor
@Twysthor 3 жыл бұрын
Instead of "attacks" in the attack message I have "offense[rand()%10]" where offense is an array of strings like "gut punches", " low kicks", "slams". "Hulk slams Thor and deals 18 damage" sounds cool haha
@derekbanas
@derekbanas 3 жыл бұрын
That’s cool :) I’m happy you had fun with it
@mcmiloy3322
@mcmiloy3322 6 жыл бұрын
My program: github.com/mcmiloy/cpp_tutorial/blob/master/sh_battle.cpp (edit: works properly on Ubuntu, does weird things on Windows for whatever reason)
@shahrirosman2255
@shahrirosman2255 6 жыл бұрын
Hi Derek, sorry if this not related to the video. I just want to ask is VB and VB.Net same?
@derekbanas
@derekbanas 6 жыл бұрын
Hi, VB6 and VB.Net both have similar keywords, but they are quite different from each other
@danieldaszkiewicz7313
@danieldaszkiewicz7313 5 жыл бұрын
Please respond :DDD As someone who is just beginning learning C++ in college and just scratched the surface should I dip my toes in object-oriented programming or wait till I have a better understanding of the basic stuff?
@derekbanas
@derekbanas 5 жыл бұрын
C++ is completely an object oriented language so it is very important to understand it to understand C++. If you have specific questions I'm happy to answer them in comments. I answer all my questions. I'm here to help, but I may not get to your question till tomorrow because it is almost bed time:)
@danieldaszkiewicz7313
@danieldaszkiewicz7313 5 жыл бұрын
@@derekbanas Well one question I have is should I depend on my professor to teach me C++ or take the wheel myself and have my professor be like a refresher?
@derekbanas
@derekbanas 5 жыл бұрын
I always taught myself using books that worked best for me. I always felt the textbooks the professors choose were rather poor.
@danieldaszkiewicz7313
@danieldaszkiewicz7313 5 жыл бұрын
Derek Banas that’s great thank you!
@andrejpetrushevski9880
@andrejpetrushevski9880 6 жыл бұрын
Hi, thank you for this video but i have one question: Why are you using std::string or std::cout ? i've never seen that before, what does it do?
@derekbanas
@derekbanas 6 жыл бұрын
I'm happy you liked it :) If you use namespace std you don't need the std:: part. I choose not to do it because you can have naming conflicts when you use it
@insanity2753
@insanity2753 4 жыл бұрын
I
@exodus8814
@exodus8814 6 жыл бұрын
Hey Derek:) Will you cover structs, enums and templates?
@derekbanas
@derekbanas 6 жыл бұрын
Yes definitely
@exodus8814
@exodus8814 6 жыл бұрын
Derek Banas Thanks very much :) it'd be also cool to do another Pointer video. Like the difference between const char pointer and char consr pointer, and char** double pointer as well as smart pointers. Sorry for all of this, just a suggestion :)
@mcalex4747
@mcalex4747 3 жыл бұрын
Hey Derek, please give me an Idea please, for my interview it'll be usefull to have a little project, can you please give me an idea about a little program using OOB programming ?
@Lucas-md8gg
@Lucas-md8gg 3 жыл бұрын
GUI project
@r72rock
@r72rock 6 жыл бұрын
My Battle::StartFight was slightly different. I had Attack() as a method that took the other warrior as a parameter, and calculated the damage done to the warrior passed to Attack(). If no one died after both of them had attacked each other, then it would rerun the StartFight function. Thanks for these tutorials! Cheers! void Battle::StartFight(Warrior* war1, Warrior* war2) { war1->Attack(war2); if (war2->IsDead()) { std::cout GetName() IsDead()) { std::cout GetName()
@micksail3341
@micksail3341 2 жыл бұрын
That was the Most Enjoyable C++ OOP Class I Ever Went To. You Out Did Yourself in showing that game concept using OOP. OutStanding. You just made Coding Exciting!!!! God Bless and Take Care.....KABANGA!!!!!! ------------ End of Line -------------------
@derekbanas
@derekbanas 2 жыл бұрын
Thank you for the great message :) I'm very happy you enjoyed watching warriors fight to the death
@StickyYuki
@StickyYuki 5 жыл бұрын
my prof give a assignment to us. One of the question is what is two types of instance??
@KallMeChris
@KallMeChris 6 жыл бұрын
My problem with watching your tutorials is that I don't know how to put it all together, im having trouble finding out what I want to create using the programming language c++, you teach about 6 different things that relate to the topic of the video but I don't know if I should create specific file for them for organization and just to keep around, I love the series by the way going to start from the beginning again, can you please tell me what should I do?
@derekbanas
@derekbanas 6 жыл бұрын
This series is trying to teach how to solve problems using C++. The goal is to do your best to solve the problems, but getting them correct is definitely not required. After I show the solution the goal is to understand how I solved it. Then you can use the techniques demonstrated to recreate my solution or make something similar.
@moofymoo
@moofymoo 5 жыл бұрын
I cannot watch this, ToString() that does not return a string makes me very angry!
@Suekru3
@Suekru3 4 жыл бұрын
@Beautiful Greece Most object-oriented languages have the practice of using getters and setters. In most real-world applications you will see them being used and I guarantee employers will look for you to use them as it is the standard. Especially since you'll probably be working on a project with someone else and getters and setters are already implemented suddenly going off and using the public variables directly would look very messy.
@_________________404
@_________________404 4 жыл бұрын
@Beautiful Greece Exactly... Getters and setters is something that appears almost in every OOP tutorial but no one really says the reason or purpose of using them. It's completely useless to create getters and setters that just set and return the value because this is NOT how encapsulation works. Something is encapsulated when it's a part of a larger system and the particular components that don't need to be seen or accessed by the "user" are encapsulated. For example, if you have a "clock" object, the internal mechanism and "gears" of the clock are the things that are encapsulated because the user doesn't "see" those. I'd say that the theory of OOP is much more important than the code, it's the thing that's missing from these videos, once you learn basic OOP theory it'll be much more easier and understandable.
@redvenom9304
@redvenom9304 6 жыл бұрын
Derek, Can you do data structures in c, please!
@derekbanas
@derekbanas 6 жыл бұрын
I'll see what I can do
@isaacyuki1
@isaacyuki1 3 жыл бұрын
Why u had to write int Anima::numofAnimals=0 outside of the class? I didn't get that.
@exodus8814
@exodus8814 6 жыл бұрын
Thanks for the hard work Derek :) Edit: So it's been 10 videos by now, but how can I remember all of the information/code you previously explained?
@derekbanas
@derekbanas 6 жыл бұрын
Thank you for staying an active subscriber for so long :D I greatly appreciate it. I have very few.
@exodus8814
@exodus8814 6 жыл бұрын
Derek Banas Much love:))) I would definitely support you till the end of my life :) I do watch the ads on each one of your videos. You deserve all the best. :) I still do remember few active subscribers that I used to chat with like Gert, NikolaticP and akagami. Don't know why they aren't active anymore, probably busy :)
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) In exchange I'll only ever use 1 5 second ad no matter how long the video is. I hate it when I'm watching something and an ad pops up! Yes I miss hearing from past people that used to message me all the time :( I understand though. My videos aren't exactly passive watching experiences.
@derekbanas
@derekbanas 6 жыл бұрын
Have you ever tried SRS? It is like digital flash cards. I use this to study / memorize Japanese characters and words ankiweb.net
@exodus8814
@exodus8814 6 жыл бұрын
Derek Banas Your videos are amazing I've learned a lot thanks soo much :) Its really awesome that I can now program using your tutorials. It's been my dream actually. Thanks for making it happen. You rock!!! Thanks a lot for SRS method. I'll check it right now!
@mahnazha
@mahnazha 5 жыл бұрын
akhhh, I wrote it very differently. I thought we had to put the code inside the start fight and I did not get the hint. It works but my code is not optimized at all. and since I could not put 2 ifs at the same time with the same condition in my code, my warrior's health goes below 0 and it prints it. I feel blue :-((((( and a question, I used pointers to pass them to the start fight. Well I instantiated my warrior class using new. Is that a problem?
@derekbanas
@derekbanas 5 жыл бұрын
You did a great job!!! To get that close to the solution is fantastic! A+
@TheJaniczek
@TheJaniczek 5 жыл бұрын
All that ... " messy" stuff with all those constructors is still blurry for me. Why do we have to create all that mess ? Why we have to use this->weight = weight; and other stuff? Why is there a copy of the constructor which is the same as void Animal::SetAll(xxx xxx xxx) ? Don't fully get that part ... I mean I get the usage - but I don't get when and why I should be using it. All the VIDs are great stuff !! :)) Thanks for that! :)
@Ab-cj6gl
@Ab-cj6gl 5 жыл бұрын
I'm so hyped that I found you 😇
@derekbanas
@derekbanas 5 жыл бұрын
Thank you :) I'm happy you like my videos
@Ab-cj6gl
@Ab-cj6gl 5 жыл бұрын
@@derekbanas you the best thanks for existing
@derismekentz1
@derismekentz1 2 жыл бұрын
Why use printf instead of cout?
@fernandofiauxdemoraes5458
@fernandofiauxdemoraes5458 6 жыл бұрын
As originally Java and C# programmer, when it comes to OOP, I'll ask. What's the diference between defining methods in and outside of the class?
@derekbanas
@derekbanas 6 жыл бұрын
You can do either
@fernandofiauxdemoraes5458
@fernandofiauxdemoraes5458 6 жыл бұрын
Yes I noticed that. But I was also reading something about compiler performance and inline functions. Could you elaborate that to me a little better? It ended up not being that clear. Thanks!
@ghostwalker3860
@ghostwalker3860 4 жыл бұрын
Hello! Nice tutorial but I was wondering why did you used printf instead of cout in the second part of the video?
@derekbanas
@derekbanas 4 жыл бұрын
Just to show that you can use printf. I try to cover everything
@ghostwalker3860
@ghostwalker3860 4 жыл бұрын
@@derekbanas oh ok, thank you!
@patrickr6340
@patrickr6340 5 жыл бұрын
What is your definition of OOP?
@derekbanas
@derekbanas 5 жыл бұрын
The process of modeling real world objects and creating an environment through which you can simulate interaction between objects, or the process through which you can simulate systems. That is not a dictionary definition :)
@ianphil397
@ianphil397 4 жыл бұрын
That was really fun. Interesting watching your solution; I did it the other way round, all block and damage calculations were done in the Warrior class; my Battle class was very slim: class Battle { public: static void StartBattle(Warrior& ContestantOne, Warrior& ContestantTwo) //Pass by reference or new instances of the warriors get's created. { bool FirstAttacker = (bool)(rand() % 2); int ReturnedHealth = 1; while (0 != ReturnedHealth) { if (FirstAttacker) { ReturnedHealth = ContestantTwo.ReceiveHit(ContestantOne.Attack()); } else { ReturnedHealth = ContestantOne.ReceiveHit(ContestantTwo.Attack()); } ~FirstAttacker; } } };
@derekbanas
@derekbanas 4 жыл бұрын
Thank you for sharing
@amshiv
@amshiv 2 жыл бұрын
I don't know why but I'm getting infinite loop in that warrior fight code.🤔 I checked code few times and I'm unable to spot any error. Any idea where it went wrong?
@amshiv
@amshiv 2 жыл бұрын
Also I'm getting negative numbers in their damage or health attributes
@exodus8814
@exodus8814 6 жыл бұрын
@Derek Banas @Amir is asking how to add an image to "access" or "axis" through C++. He probably means about Microsoft Access. Also, he's having trouble finding the cheat sheet, link it to him. I did but for whatever reason my comment didn't show up publicly so I deleted it.
@derekbanas
@derekbanas 6 жыл бұрын
Thanks for helping :)
@zulumopuku5370
@zulumopuku5370 6 жыл бұрын
wow u are back.. please can you tell if your android videos are still good even after all these years?. things have changed a lot in the industry...
@derekbanas
@derekbanas 6 жыл бұрын
Yes this series is largely still current kzbin.info/www/bejne/pHOnZauefZqpf6c
@saitakay9733
@saitakay9733 6 жыл бұрын
How many videos will you make about c++?
@derekbanas
@derekbanas 6 жыл бұрын
I have no idea. As many as it takes to cover just about everything about the language
C++ Tutorial 11 : Polymorphism
18:48
Derek Banas
Рет қаралды 75 М.
OOP Class Inheritance and Private Class Members - Python for Beginners!
16:12
لقد سرقت حلوى القطن بشكل خفي لأصنع مصاصة🤫😎
00:33
Cool Tool SHORTS Arabic
Рет қаралды 29 МЛН
Я обещал подарить ему самокат!
01:00
Vlad Samokatchik
Рет қаралды 9 МЛН
Best Toilet Gadgets and #Hacks you must try!!💩💩
00:49
Poly Holy Yow
Рет қаралды 22 МЛН
路飞太过分了,自己游泳。#海贼王#路飞
00:28
路飞与唐舞桐
Рет қаралды 39 МЛН
C++ Tutorial 14 : Templates & Iterators
22:13
Derek Banas
Рет қаралды 74 М.
Introduction To Classes And Objects | C++ Tutorial
11:49
Portfolio Courses
Рет қаралды 51 М.
Stop, Intel’s Already Dead!
13:47
Linus Tech Tips
Рет қаралды 154 М.
C++ Tutorial 12 : Operator Overloading & File I/O
28:30
Derek Banas
Рет қаралды 35 М.
C++ Tutorial 13 : Advanced Functions
18:27
Derek Banas
Рет қаралды 67 М.
C++ Tutorial : C++ Full Course
2:22:52
Derek Banas
Рет қаралды 323 М.
Object Oriented Programming (OOP) in C++ Course
1:30:26
freeCodeCamp.org
Рет қаралды 2,5 МЛН
5 Tips For Object-Oriented Programming Done Well - In Python
16:08
لقد سرقت حلوى القطن بشكل خفي لأصنع مصاصة🤫😎
00:33
Cool Tool SHORTS Arabic
Рет қаралды 29 МЛН