The difference between public and private access modifiers in C++ classes is discussed with an example. Source code: github.com/portfoliocourses/c.... Check out www.portfoliocourses.com to build a portfolio that will impress employers!
Dang, your courses are so underrated, yet so helpful... and today's views of 31k is not matched by lousy 876 likes. C'mon people, don't just watch, pay your dues and hit the like button for these no fuzz and straight to the point tutorials.
i have 3 hours to my final exam. your channel has helped me a lot so far, thank you ❤️ ps: text based AI LMs still can't explain topics better than humans
You're very welcome, I'm so glad to hear the channel helped you out! :-) And I'm glad to hear humans are still winning the race against the machines, at least for now. :-P
Thank you for all of your helpful videos. Also would like to say its nice to find a Canadian creator -- (if you are canadian! I have a similar accent). Keep doing what you're doing and thanks again.
You're welcome, I'm glad you find them helpful! :-) And haha yes, I'm Canadian. That's funny that you could tell by the accent, I never really think of myself as having an accent but I suppose we all do.
can i just say: fck me. finally someone explaining it well. i am follwoing many c++ tutor and i dropped the ball with all their explanation. especially because fk knows why they are using nonsensical variable and class names when it is crutial to be clean and straightforward when one is just learning a new skill. so thank you for that. i am superglad i found this channel.
Well explained, but i would add why do we even use it ? In which cases ? Why just not use const if i am intending not to make changes in it ? Real world reasons why i would choose to make some functions or variables private.
In this video I am using Xcode, which is available free on a Mac: developer.apple.com/xcode/. On Windows, Visual Studio is pretty good: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-qWPlRubVQ38.html. :-D
I have difficulties understanding the need for getters and setters, because if you can access it anyway in the public section then it (for me) seems exactly the same as simply just having the salary in the public section? How can this method be more secure if you can set salary and get salary from public? 4:20
The idea is that getters and setters can do things with the data before getting and setting. So maybe before setting a value, the setter can ensure the value is within a valid range. And maybe before returning the data, the getter can convert the format of the data. The exact usefulness of getters and setters is something that is debated by people though, so you're right to question it. :-)
Great question Caleb! :-) If we want to give access to private members, we can use public members to do so, but it’s not a requirement that we do this. Sometimes it’s useful to have members that are private without giving access to them through public members, for things the class needs to use “internally” but not expose to the “outside world”.
Great question Akash! This answer here talks about classes and scopes: stackoverflow.com/questions/55092387/what-is-the-scope-of-a-class-declaration-in-c. :-) If you want to learn more about namespaces they are covered in this video here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-0EtnWcRild4.html.