So I amI'm watching this video, it's part 13 of something like 73 videos ona C++ tutorial video. It is talking about variables inside classes and assert that to use the var, Ivariables should make it PRIVATE and not public..be marked private. But then, at timesIt explains that if I might want to use itthem publicly outside the class so then there is this way to MAKE, I should do it public indirectly usingthrough functions.
That's all good and all, I understand WHY a variable SHOULD be private, this keeps that chances the programmer will accidentally cause an error low.
The part I do not understand is if the programmer does what this guy shows and finds a way AROUND making the variable private and converts it to public using this way, what'sWhy? What's the difference. Now? It looks like the variableresult is public... He just did the same thing, except that instead of having one line of code, I now he madehave like 9 or 10 MORE lines of code which seems the opposite direction that a programmer would like to go. Less is more usuallyLOC to do the same thing.
Can someone explain why converting a private variable in a class to public within the class rather than just making it public right out the simple way is any different and more efficient?