Getters & Setters | C++ | Tutorial 30

Поделиться
HTML-код
  • Опубликовано: 4 янв 2025

Комментарии • 46

  • @davidjuniormz
    @davidjuniormz 5 лет назад +24

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

  • @ΙσίδωροςΚαλαμάρης
    @ΙσίδωροςΚαλαμάρης 2 года назад +5

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

  • @AlekVS
    @AlekVS 8 месяцев назад

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

  • @daboxguy3848
    @daboxguy3848 3 года назад +6

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

  • @jackdougie8
    @jackdougie8 5 месяцев назад

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

  • @soloman3140
    @soloman3140 10 месяцев назад +1

    Good explanation sir

  • @joshuavincent7884
    @joshuavincent7884 4 года назад +7

    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

    • @voynich7119
      @voynich7119 2 года назад +4

      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.

    • @pizzaguy_
      @pizzaguy_ 2 года назад +1

      its bad for the view time, if the viewer doesnt know what a vector is they'll have to look it up

    • @g4zzen245
      @g4zzen245 Год назад

      just make a string array and for loop it checking if aRating == arr1[i] for example

  • @daneshsengottaiyan7221
    @daneshsengottaiyan7221 3 года назад +3

    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

  • @manousosm.9810
    @manousosm.9810 2 года назад +1

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

  • @antonmakeyenko4018
    @antonmakeyenko4018 4 года назад +9

    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

    • @halumetri8957
      @halumetri8957 3 года назад

      thanks actually makes a lot of sense and didn’t think about it nice explanation

    • @musikalniyfanboichik
      @musikalniyfanboichik 3 года назад

      thank you for letting us noobies know

    • @nyxatnight45
      @nyxatnight45 3 года назад +1

      Could you please explain that passing the aRating to SetRating part 6:37 ....im a newbie so please help me out

  • @j3froc63
    @j3froc63 5 лет назад +1

    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??

  • @okerelovedayrichman7743
    @okerelovedayrichman7743 5 лет назад

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

  • @mangeshmane1749
    @mangeshmane1749 6 лет назад +3

    Hey I want default and parameters constructor in cpp

  • @paulvaldivia8995
    @paulvaldivia8995 2 года назад

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

  • @kino9521
    @kino9521 4 года назад +1

    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?

  • @adelem8293
    @adelem8293 Год назад

    so helpful, thanks

  • @mukongshu
    @mukongshu 3 года назад

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

  • @mukongshu
    @mukongshu 3 года назад

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

  • @Ozla102
    @Ozla102 4 года назад

    UR SO GOOD, lovin it

  • @4DoGamerHDD
    @4DoGamerHDD 6 лет назад

    Good way in explanation

  • @nishithbaravkar7549
    @nishithbaravkar7549 4 года назад

    thanks a lot mike this video was good

  • @jeezx689
    @jeezx689 3 года назад +2

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

  • @kellenwang4606
    @kellenwang4606 6 лет назад

    That's Nice, man

  • @taraspokalchuk7256
    @taraspokalchuk7256 5 лет назад +6

    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.

    • @melvin4524
      @melvin4524 Год назад

      You're right, there is no need for getters and setters, You should learn from people like Casey Muratori

  • @kian5426
    @kian5426 Год назад

    The goat

  • @shrivatsankchari1729
    @shrivatsankchari1729 3 года назад

    top lad mike

  • @Ryan-ez4op
    @Ryan-ez4op 5 лет назад

    HELPFUL!

  • @os5803
    @os5803 9 месяцев назад

    thx ((:

  • @RealityCheck6969
    @RealityCheck6969 Год назад

    This white background hurts my eyes.

  • @mukongshu
    @mukongshu 3 года назад

    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...

    • @BriariusTitan
      @BriariusTitan 3 года назад +2

      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.

  • @rodolfoalva422
    @rodolfoalva422 5 лет назад

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

    • @joshuavincent7884
      @joshuavincent7884 4 года назад +1

      not saying you're an idiot, but you're trying to learn something without knowing the basics

    • @joshuavincent7884
      @joshuavincent7884 4 года назад

      @@rodolfoalva422 if you know the basics why are you complaining that you don't understand the code in this video?

    • @programmer4833
      @programmer4833 3 года назад

      Three words : you are stupid.

  • @rodolfoalva422
    @rodolfoalva422 5 лет назад

    tutorial is so useless! I have to skip and go back to see other code that matters!!!

    • @lucasaraya1673
      @lucasaraya1673 5 лет назад +1

      its part 30 of a series what do you expect