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
That's the one thing I did differently when I copied this for practice. It looks way cleaner. I guess it would overcomplicate the video though, since vectors are another topic that maybe not everyone knows.
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
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??
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.
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...
when you let someone else use your code or if you forget that you want to use certain parameters, you use getters and setters. he actually explains this very very well and has a good and simple examples, unlike a lot of other teachers.
Clear and straight to the point... Thank you, that was really helpful.
Really helped me to clear my mind about why we need getters & setters and the differences with the constructor. Thank you!
I kept hearing about setters and getters but never really understood their utility until this very video. Thank you so much
Me :"Mom I want to watch The Avengers."
Mom : "Sorry John, but it's rated dog!!!?"
John isn't old enough to watch dog rated movies
Bro you're a lifesaver. such a good explanation. Thank you so much
Good explanation sir
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
That's the one thing I did differently when I copied this for practice. It looks way cleaner. I guess it would overcomplicate the video though, since vectors are another topic that maybe not everyone knows.
its bad for the view time, if the viewer doesnt know what a vector is they'll have to look it up
just make a string array and for loop it checking if aRating == arr1[i] for example
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
Really easy to understand and very helpfull indeed! Great job!
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
thanks actually makes a lot of sense and didn’t think about it nice explanation
thank you for letting us noobies know
Could you please explain that passing the aRating to SetRating part 6:37 ....im a newbie so please help me out
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??
Very Very Very helpful thanks for your tutor, very straight...
Hey I want default and parameters constructor in cpp
If I have a private member of type bool, Do I need a getter and setter for that?
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?
so helpful, thanks
why do you see average is not in "movie “ class? there's a "MOVIE" in front of averanger in main function
another question, why do you put STRING aRating in void function? arating has already been defined as string?
UR SO GOOD, lovin it
Good way in explanation
thanks a lot mike this video was good
So why can't my prof explain it this simply?
That's Nice, man
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.
You're right, there is no need for getters and setters, You should learn from people like Casey Muratori
The goat
top lad mike
HELPFUL!
thx ((:
This white background hurts my eyes.
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...
when you let someone else use your code or if you forget that you want to use certain parameters, you use getters and setters. he actually explains this very very well and has a good and simple examples, unlike a lot of other teachers.
not saying you're an awful explainer. just can see everything else!!!!
not saying you're an idiot, but you're trying to learn something without knowing the basics
@@rodolfoalva422 if you know the basics why are you complaining that you don't understand the code in this video?
Three words : you are stupid.
tutorial is so useless! I have to skip and go back to see other code that matters!!!
its part 30 of a series what do you expect