For greater operator (>) you can easily use the less operator ( (const Box& box2){ return (!(*this < box2)) }
@vyasramankulangara88046 жыл бұрын
I finally understand why operator overloading is useful. Thank you so much!
@derekbanas6 жыл бұрын
I'm happy I could help :)
@tylerburgess85436 жыл бұрын
I think I'm starting to sound like a broken record recommending your channel :D Great work!
@derekbanas6 жыл бұрын
Thank you :) I greatly appreciate that!
@electronix2595 жыл бұрын
Man, for some reason overloaded operators were always escaping me during classes, just couldn't understand it. Now I realize how easy they are.
@derekbanas5 жыл бұрын
Happy I could help :)
@jorgeherrera10743 жыл бұрын
Love the explanation, however, better to return a reference to the object than to return void on these overloaded operators. If you return a reference then you can do things like ObjA = ObjB = ObjC or you could also do things such as ObjA < ObjB < ObjC and you can evaluate to true/false in a conditional whereas return of void will be a compiler error
@luis6226 жыл бұрын
Hey, I'm a big fan of your videos! Thank you for all the time and effort on your part. I'm a big fan of using cerr for example as part of the else statement if the file is not open. Maybe it would be a good idea to implement for your future videos to make your viewers aware of that function. Thanks again!
@derekbanas6 жыл бұрын
Thank you :) Yes I'm not finished covering File I/O. This was but a sample
@andrewman1786 жыл бұрын
I would love to see more videos full of problems and solutions using these kinds of concepts. Great work on this series so far!
@derekbanas6 жыл бұрын
Thank you :) I'll always do my best to include at least one problem.
@clbgrmn6 жыл бұрын
For your overload of the increment operator, you're returning a pointer to a box. But, the return statement returns the data at 'this'. Isn't 'this' already a pointer to a box? So using '*' on this gives you a box object. Seems like it should be returning 'this' rather than '*this', right?
@AdnaanBheda6 жыл бұрын
Why are we using ios_base instead of ios ? Can you please elaborate on that? Thanks for the awesome videos Derek, I'm loving every series of yours :)
@samangharatchorlou65726 жыл бұрын
Hey Derek, great videos, so much information! Have you done a video on best coding practices? Like how to structure your code, how to best write a function (i.e. how long or specific to a task should it be), when to and not to use classes (should I wrap all my functions in a class, like you did for the Battle problem, and why?), file names and stuctures etc. Great stuff :).
@derekbanas6 жыл бұрын
Thank you :) Sure check out my object oriented design, and refactoring tutorials
@ethanmiller52235 жыл бұрын
This video is literally amazing thanks
@derekbanas5 жыл бұрын
Thank you very much :)
@WiseLyonsPowerfulLyo6 жыл бұрын
I should start by saying that I am not particularly well versed in programming yet. You should do an in-depth video(s) about larger abstractions of object oriented systems within an OO codebase. I mean it would be really helpful to understand the theory, reasoning, and coded examples of how systems of objects and code are *rightly* supposed to work together. The only good book that I've found that particularly teaches about this is "Refactoring in Large Software Projects" by Martin Lippert and Stephen Roock. If you want I can send a bunch of photographs of the pages to you. Let me know. Another few aspects, that come to mind, that I think should be adequately addressed are things like naming conventions; and composition, dependencies, and relationships of classes. I would like to know a broad and in-depth theory and methodology of why certain objects are used within specific classes and not others. Also, why certain relationships exists as *opposed* to other possible relationships. Now, keep in mind that most classes are not modeled after real world things but are, apparently(I guess), mainly modeled to create order and structure and logically participate in larger systems of order and structure. In fact, if a larger system should need to change then a class may need to either change to logically work with and accommodate the larger system OR the larger system, itself, may need to HEAVILY be reworked *around* the class - to accommodate such class. I want to understand, among other things, how classes and systems of classes should be written and as well as the broader view of how these systems should be thought of. Thanks.
@derekbanas6 жыл бұрын
I plan on covering object oriented design. I've already covered it with Java here kzbin.info/www/bejne/nHu6Z2iNpJx8fqs and I covered refactoring here kzbin.info/www/bejne/rJm8fGamebqcoM0
@WiseLyonsPowerfulLyo6 жыл бұрын
*@Derek Banas* *-"I plan on covering object oriented design. I've already covered it with Java here"* Yeah I've downloaded and partially watched your previous vids on OO design and refactoring. So far they are very good btw. I believe your previous vids only partially covered the concepts of larger abstractions of OO *system* designs and it's theory . What, it seems, you originally lectured more about were the concepts of *smaller* abstractions of OO *system* designs and it's theory. As a matter of fact, I think that you could/should have gone into more detail about smaller system design theory *also* , and that would have been SO much more awesome! If you even know how, that is..... So I guess I'm saying it would be SO helpful and awesome to lecture about both BIGGER and smaller OO *system* design and it's theory. I've skimmed through a few books on refactoring and the book, "Refactoring in Large Software Projects" by Martin Lippert and Stephen Roock is NOT very focused on refactoring merely the pieces of systems but rather the entirety of the systems themselves. Other refactoring books focus much more on the smaller aspects, and, yes, I know the larger is made out of the smaller. If you have a Safari account then maybe you could check out this book. I'm telling you - it ain't the same. Also, if you want I will send you many android photos from the book.
@xavierlesperance61563 жыл бұрын
Hey Derek, thanks so much for the videos they are great. I have a quick question about overloading the increment and decrement operators, typically ++i and i++ give the same results but in the case of the Box class only the ++box was overloaded how would you go about overloading box++ as well?
@gimmegaming53454 жыл бұрын
I''m hoping you can help me understand but why does "operator const char*(){}" not have a return type like other functions? Is it something to do with being a pointer?
@tmjromao6 жыл бұрын
Thanks for the video. Well explained and quite informative.
@derekbanas6 жыл бұрын
Thank you :)
@danigol66635 жыл бұрын
awesome man. its helping me a lot.I would have Liked it thousand times if possible. Thank you
@derekbanas5 жыл бұрын
Happy I could help :)
@CSSuccessGamer5 жыл бұрын
nice tutorial. I'm trying to figure out how to use the file i/o to load file and save it into a binary tree and stream out a 20 question ai game. And then save the new tree data into another file when game finishes. Do you have any related tutorials for doing this?
@exodus88146 жыл бұрын
Hey Derek :) Thanks for your hard work. Just a question, have you ever thought of contributing to the filed of Computer Science?
@derekbanas6 жыл бұрын
Thank you :) In what way? I think I already kind of do that. My tutorials are shown in numerous colleges all over the world from what I've been told.
@exodus88146 жыл бұрын
Derek Banas Awesome to hear that! I meant in a way similar to what other scientists did before. For example like Alan Turing, Dennis Ritchie etc...
@derekbanas6 жыл бұрын
I'm not that smart. The thing I seem to be better at then many people is that I can learn things quickly and then present that info in an understandable way. I definitely don't have the brain of a Turing though.
@exodus88146 жыл бұрын
Derek Banas Okay Derek. Do you think it's a bad idea to wish to contribute to a science field? Is it possible by people like me or others? Are people really born with supreme intellectual abilities or they just work hard to achieve it? Can anyone contribute to science?
@exodus88146 жыл бұрын
Derek Banas yes Derek?
@Zen-lf7zr6 жыл бұрын
Hey Derek, I didn't understand at 6:19 how you were able to use boxString without declaring it anywhere, what kind of object is it? Also could you tell me more about how to differentiate what return type each overloaded operator should have. Thanks in advance :)
@Conorkc863 жыл бұрын
I bet you haven't included #include try that and let me know if it worked
@Zen-lf7zr3 жыл бұрын
@@Conorkc86 I don't remember haha but I'm decent at C/C++ now thanks to these videos.
@rapidreaders77415 жыл бұрын
Is there a way to use format specifiers when writing doubles to a file?
@yankomirov42904 жыл бұрын
Great tutorial, thank you very much!
@derekbanas4 жыл бұрын
Happy I could help :)
@nadrogiranihibiskus51866 жыл бұрын
is this operator overloading stuff really usefull in programming ?
@derekbanas6 жыл бұрын
Yes very much so
@brodoswaggins53874 жыл бұрын
the getline() in the readFromFile's while loop return an error saying 'no instance of getline matches the argument list'. would there be an updated code for VS2019? std::cin seems to work fine lol
@XxD4rkAssassinxX6 жыл бұрын
Coming from Java, I find operator overloading really amazing
@derekbanas6 жыл бұрын
C++ is the language that can do everything :)
@AndrewDChristie3 жыл бұрын
Awesome Video
@derekbanas3 жыл бұрын
Thank you very much :)
@mcalex47474 жыл бұрын
Tell me please when EXACTLY do you use this "&" as a REF, I was never able to understand it.
@propkillerr4 жыл бұрын
When you need to pass an argument as a reference. It's not really hard to understand.
@berndrichter15496 жыл бұрын
Derek im a fan of your videos I would be happy if you can do same kind of tutorials for javascript and arduino
@derekbanas6 жыл бұрын
Thank you :) Arduino will start soon. I'll see about JS
@techtalktoe97584 жыл бұрын
Derek has a great JavaScript playlist. Check it out!
@ozbity32436 жыл бұрын
Will you be making a nim Lang tutorial? Plus love your videos
@derekbanas6 жыл бұрын
Thank you :) I will definitely if I get requests
@chickerinoradio66174 жыл бұрын
what if i want to open a file in a different directory?
@luckyluuk87885 жыл бұрын
Hi Derek, quick question: how would one call the overloaded const char* operator? I can't seem to get it working.
@Pensive_1175 жыл бұрын
He doesn't like answering people. I knew him in college; he's extremely anti-social.
@coder00794 жыл бұрын
I had this same question, and it took me a bit of searching to solve it. What I believe he is doing with the const char* operator is called a "User Defined Conversion." An internet search should make it clear.
@bluewatermelon32534 жыл бұрын
With that line, he defines how conversion to const char* will behave. For example, if you had code like this: Box green(10,20,40); int number = green; You would get an error because the class (green) cannot be converted to int (number) But, if you define operator overloading in class like this operator int(){ return Box->length + Box->height + Box->width } And that would mean int number = green that variable "number" stores sum of box "green" dimensions. So, when you have to do datatype conversion you just use the following syntax: operator datatype_name(){ return //what you want to return with datatype_name } Hope this clarifies what are you confused about
@ronanpatrick57633 жыл бұрын
Thanks
@derekbanas3 жыл бұрын
Happy to help :)
@Stormhatt5 жыл бұрын
Why does boxString have to be stored outside of the operator const char*() function?
@AntonioAstorino5 жыл бұрын
const char* is a pointer. If you don't store boxString, as soon as you return from the function operator const char*() the pointer will be deleted. Just try and see what happens :) Great question by the way. Not great answer though. Insist if I haven't been clear enough
@Stormhatt5 жыл бұрын
@@AntonioAstorino Makes sense, thanks for the explanation :)
@AntonioAstorino5 жыл бұрын
@@Stormhatt Any time!
@Gosei_Nakara6 жыл бұрын
I love you.
@derekbanas6 жыл бұрын
You're very kind :) Thank you
@MdmanProductions6 жыл бұрын
You should include LSEEK!!!
@braindeveloperdimensional55796 жыл бұрын
can you please make a tutorial on how to write a clean and correct code in C++ and makefile tutorial also, I am stuck with a C++ library. I can't compile it which I found on GitHub. Please Help!
@derekbanas6 жыл бұрын
I'll see what I can do
@souravmukherjee1755 жыл бұрын
why you dont use using namespace std..
@derekbanas5 жыл бұрын
To avoid naming conflicts
@bhargav74766 жыл бұрын
Part 12 of ? How many parts left ?
@derekbanas6 жыл бұрын
Sorry, but I don't know. These aren't scripted out. I just will keep making them until I feel I've covered most everything
@bhargav74766 жыл бұрын
Derek Banas I guess I will keep watching then
@derekbanas6 жыл бұрын
I doubt I'll make that many. My videos tend to be rather long. I can cover just about everything in much less
@bhargav74766 жыл бұрын
Suyggyu 7 years ago
@bhargav74766 жыл бұрын
Derek Banas Helping me score better grades in my diploma. Thanks
@ronistiawan11306 жыл бұрын
when are you going to start making GUI?
@derekbanas6 жыл бұрын
Sorry I don't know. After I cover the core language
@braindeveloperdimensional55796 жыл бұрын
You mean GUI in C++?
@braindeveloperdimensional55796 жыл бұрын
Derek Banas If you are going to create a GUI series then please do it in any game programming library like :- OpenGL, SDL or Allegro5. Game programming libraries offer a lot more than gtk+, Qt or MyGUI. Please do it in game library if you could.
@derekbanas6 жыл бұрын
I haven't decided which I'll use yet
@exodus88146 жыл бұрын
Could you answer my last question on my previous comment Derek?
@derekbanas6 жыл бұрын
Sorry, KZbin didn't send it to me. Yes just about anyone can achieve anything if they are motivated and have a good plan. I have met many what you'd call genius types. I think they accomplish so much because they all tend to have a strong focus on one subject. That is why they achieve so much, but also why other parts of their life are a mess. I think anyone can cultivate a strong enough focus on something they are passionate about. Look to the achievements of others and to entertainment to cultivate passion. Surround yourself with the best teachings from numerous sources. Then set aside time every day and you can do just about anything.
@shahidkhan02196 жыл бұрын
Super
@derekbanas6 жыл бұрын
Thank you :)
@dx2002sg3 жыл бұрын
Char *() is an c++ operator? interesting.
@2271masoud6 жыл бұрын
operator overloading and file I/O in nutshell. Thanks Derek