I have to confess something, I never really understood classes in programming. I look at "class myClass" and public vs private members, and I am confused.

@masterofthetiger If an object is a collection of variables and functions (called properties and methods respectively); then a class is an object template. Each instance of an object is "instantiated" with a template, which can then be "extended" or modified. Some objects are so complicated that their functions need other functions or variables. That is where a private member comes in. It allows only the object itself to use it, whereas public members are accessible from outside the object.

@masterofthetiger imho OOP isn't what it is cracked up to be. You can't evade all problems with it, and can set up mental overhead that might not actually be worth it.

Private members or at least a convention to indicate which member are internal sound like a good idea, though.

So in C++ if it is in a private section of a class, the method can only be accessed by methods defined on the same class at the same time. Protected ones are accessible by method defined derived-downstream.

@masterofthetiger usually private functions are like utilities for the public ones?

Golangs approach of interfaces seems better to me.. That said, don't *really* have much experience with either.

Sign in to participate in the conversation
There's Life

A social network website (Mastodon instance) devoted to the new life only found in Christ.