Getters & Setters | C++ | Tutorial 30

preview_player
Показать описание

Throughout the course we'll be looking at various topics including variables, arrays, getting user input, loops, conditionals, object orientation, and much more.
Рекомендации по теме
Комментарии
Автор

Clear and straight to the point... Thank you, that was really helpful.

davidjuniormz
Автор

Really helped me to clear my mind about why we need getters & setters and the differences with the constructor. Thank you!

cvdtzol
Автор

I kept hearing about setters and getters but never really understood their utility until this very video. Thank you so much

AlekVS
Автор

Bro you're a lifesaver. such a good explanation. Thank you so much

jackdougie
Автор

It is good, but I can't run the full code on Getters and Setters part. It is showing me 2 errors on the if line

daneshsengottaiyan
Автор

Really easy to understand and very helpfull indeed! Great job!

manousosm.
Автор

Using the same "aVariable" method i get the "not declared in scope" error. Am I doing something wrong? Do I have to declare them too?

kino
Автор

Hey I want default and parameters constructor in cpp

mangeshmane
Автор

Me :"Mom I want to watch The Avengers."
Mom : "Sorry John, but it's rated dog!!!?"

daboxguy
Автор

Question: Can you create a trait for the 'rating' part BUT not access/edit it because it's private??


I still don't get WHY you would set a trait of a class to Private. In your example of 'ratings', you made an 'if' statement, yet you were still able to access it within the main function.
Like couldn't you have just made the 'if' statement and just ignore the fact it's private??

jfroc
Автор

another question, why do you put STRING aRating in void function? arating has already been defined as string?

mukongshu
Автор

Very Very Very helpful thanks for your tutor, very straight...

okerelovedayrichman
Автор

If I have a private member of type bool, Do I need a getter and setter for that?

paulvaldivia
Автор

would be cool to have a vector of strings containing all the ratings and then compare the user input to that instead of having that long if statement with a bunch of ORs

joshuavincent
Автор

why do you see average is not in "movie “ class? there's a "MOVIE" in front of averanger in main function

mukongshu
Автор

So why can't my prof explain it this simply?

jeezx
Автор

Being a C++ developer for over 6 years, I wouldn't recommend this tutorial simply because returning std::string from a "getter" by value is a TERRIBLE idea. It's not a JS, C#, Python, etc., where objects are reference-counted, in C++ you will get a copy (copy constructor will be called and memory will be allocated) every time you call the getter. Not to mention, that getters should be const-qualified:
const std::string& getValue() const {
return value_;
}
If you try to learn C++, you MUST care about memory and general speed. If you task doesn't need this, use another language

antonmakeyenko
Автор

i still don't see the point of getters and setters. you justify them by making an obstacle (division between private and public) that you can overcome, but I don't see the point of the obstacle either. you justify the need for private and public by saying that otherwise the users could input nonsensical data, but you could manage it in Movie() method.

taraspokalchuk
Автор

not saying you're an awful explainer. just can see everything else!!!!

rodolfoalva
Автор

if you don't put "rating" in private and only use function to make the restriction , it also works! so what's the point??? why do you put it in private? coz you don't want to get access easily, the way you use the function,

function is enough to do the restriction, i don't get it why you still put it in private...worst video i have watched you have made so far...

mukongshu