this Keyword And Use Cases Explained | C++ Tutorial

  Рет қаралды 8,084

Portfolio Courses

Portfolio Courses

Күн бұрын

How to use the this keyword in C++ including several use cases. Source code: github.com/por.... Check out www.portfolioc... to build a portfolio that will impress employers!

Пікірлер: 34
@M3t4lik
@M3t4lik 2 жыл бұрын
This is the clearest explanation of how the 'this' pointer works and is used. Thank you.
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You’re welcome, I’m glad that you found the explanation clear! :-)
@yuwownly8630
@yuwownly8630 2 жыл бұрын
Dude. Thanks for this video, it really helps a lot!!! I'm looking forward to more tutorials.
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You're welcome! 🙂 I'm glad to hear that it helped you!
@ValliNayagamChokkalingam
@ValliNayagamChokkalingam Жыл бұрын
Thanks!
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Woah, thank you so much Valli-Nayagam!!!! :-)
@ValliNayagamChokkalingam
@ValliNayagamChokkalingam Жыл бұрын
@@PortfolioCourses Thanks for the amazing tutorials! It's a really small amount but I would love to contribute more soon (still in college)!
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Good luck with your courses! :-)
@moyo8960
@moyo8960 2 жыл бұрын
The this-keyword was not necessary in the increase_age() and increase_and_output_age() methods, correct? I tested the code without it and it worked. So did you just use them for the sake of argument and to demonstrate or is it good practice to include it in such places? I was especially confused by you saying that the keyword enables the object to access its own member variables in its own member functions which is true even without 'this' being used. I would be grateful if you cleared this up, thanks! As this is the first question one of your videos left me with, I also want to use this opportunity to thank you for your content. I've only just gotten into OOP and so far tried to make my way through with stackoverflow. With your videos I'm getting a great overview and solid base to build more knowledge on later, so thank you very much for all the time and effort you put in these videos. Very concise! And I love how you slowly build your examples, structuring it in a way that you can use previous examples seamlessly to demonstrate new points!
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
It's true, you don't *need* to use the this keyword to access member variables, that is just one of the things that it allows you to do. :-) And thank you so much for the kind and positive feedback, I really appreciate you taking the time to let me know these videos are helping you and that you enjoy the structure and format. It means a whole lot to me that these videos are helpful to people! :-)
@weemanling
@weemanling 11 ай бұрын
Thank you. Finally it makes sense to me.
@PortfolioCourses
@PortfolioCourses 11 ай бұрын
You're welcome, I'm glad it helped you out! :-)
@MF18-2020
@MF18-2020 6 ай бұрын
thank you man
@Vichained
@Vichained 2 жыл бұрын
good video mate. Keep it up
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Thank you Victor, I'm glad to hear you enjoyed the video! :-D
@Vichained
@Vichained 2 жыл бұрын
@@PortfolioCourses Could you do a video of a currencies exchange proyect using OOP? I did one with 4 currencies: USD, EUR, GBP and CHF but Im sure it can be improved by a lot, so i wanna see how would you do it. Besides that, it would an awesome tutorial to learn new stuff
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
@@Vichained I could possibly do that, but what would the requirements be for the currency exchange in terms of feature and functionalities? i.e. what does it need to do.
@Vichained
@Vichained 2 жыл бұрын
@@PortfolioCourses ask user balance. What currency he has. Into which one he wants to convert it and then the result after the conversion. You could also add the feature where the user just converts a part of his overall balance, not all of it.
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
@@Vichained Interesting, there is a number of ways to go about it. Doing it an "OO way" almost makes me wonder if the idea is to use polymorphism and inheritance with a base class and derived classes for each currency. I've added this to my list of ideas, thank you, hopefully one day I can make a video on this.
@valentincafferata182
@valentincafferata182 7 ай бұрын
i finally get itttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt, thank you!!!!!
@PortfolioCourses
@PortfolioCourses 7 ай бұрын
You’re welcome! :-)
@hamudxd9497
@hamudxd9497 10 ай бұрын
Top class❤❤❤
@ieduardoms
@ieduardoms 2 жыл бұрын
Now I have a better understanding of "this". I read in a C++ book that when the creator of a class define a member as private to "protect" it from the consumer of the object, it is just a logical protection which is very easy to circumvent. So, I guess one way to circumvent this logical protection is to get the pointer of the object, then increase the pointer and read the value stored in that address. Is this correct? Thank you very much for this video.
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Great question Eduardo! :-) I think by "circumvent" they might mean that a programmer simply has to change "private" to "public" and then they have access to the member. So if a programmer wants access to something they shouldn't, really the keyword private is more of a signal to the programmer that the class was designed with the intention to keep the member private, but ultimately "private" doesn't stop the programmer from doing whatever they want.
@ieduardoms
@ieduardoms 2 жыл бұрын
@@PortfolioCourses Thank you for your answer. I was thinking it is a way how a hacker can get access to a private member.
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You're welcome! :-)
@ValliNayagamChokkalingam
@ValliNayagamChokkalingam Жыл бұрын
thanks once again! I am a bit confused with the difference between references and pointers - I am clear with pointers, dereferencing etc., in C. Getting confused with references in C++ (does & something refer the address in C++ like in C?).
@PortfolioCourses
@PortfolioCourses Жыл бұрын
So & does not mean the same thing in C when we are working with references. This video covers reference variables: kzbin.info/www/bejne/m2Snf2SIlr6Jj7M. And this video covers pass by reference: kzbin.info/www/bejne/mancpIiGj61pa7s. Maybe those can help to explain things better? But references and pointers are two different concepts, a reference "is" what it references (there is no difference between it and what it references), where as a pointer is a variable that stores a memory address of another variable (and we say it 'points' to that variable).
@ValliNayagamChokkalingam
@ValliNayagamChokkalingam Жыл бұрын
@@PortfolioCourses Thanks!
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You're welcome! :-)
@ARANDOMOPENAIUSER
@ARANDOMOPENAIUSER Жыл бұрын
my timestamp: 5:07 passing the 'this' / object-pointer as an arguement to a function
@niranjand8595
@niranjand8595 Жыл бұрын
Which IDE is this
@PortfolioCourses
@PortfolioCourses Жыл бұрын
This is Xcode on MacOS. :-)
Reference Variables | C++ Tutorial
12:04
Portfolio Courses
Рет қаралды 6 М.
new & delete Operators For Dynamic Memory Allocation | C++ Tutorial
15:52
Portfolio Courses
Рет қаралды 36 М.
Арыстанның айқасы, Тәуіржанның шайқасы!
25:51
QosLike / ҚосЛайк / Косылайық
Рет қаралды 700 М.
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
This Keyword in Java Full Tutorial - How to Use "this"
7:39
Coding with John
Рет қаралды 164 М.
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 347 М.
The "this" keyword in C++
6:08
The Cherno
Рет қаралды 264 М.
Public And Private Access Specifiers | C++ Tutorial
8:49
Portfolio Courses
Рет қаралды 50 М.
C++ this Pointer
7:22
Jamie King
Рет қаралды 50 М.
Class Templates | C++ Tutorial
12:48
Portfolio Courses
Рет қаралды 60 М.
Multiple Inheritance Deep Dive | C++ Tutorial
14:53
Portfolio Courses
Рет қаралды 11 М.
SMART POINTERS in C++ (for beginners in 20 minutes)
24:32
CodeBeauty
Рет қаралды 109 М.
you will never ask about pointers again after watching this video
8:03
What is the Difference Between a Pointer and a Reference C++
7:58
Paul Programming
Рет қаралды 447 М.
Арыстанның айқасы, Тәуіржанның шайқасы!
25:51
QosLike / ҚосЛайк / Косылайық
Рет қаралды 700 М.