Ok, I've searched for the answer to this, and either I'm not asking right, or no one has asked yet. I understand the concept of keeping member variables of a class private. But, would there be a time when it is okay, like below:
preface: I have four classes: studentSchedule(shown), studentType, taskType, courseType. All have member variables that are private, similar to below. bool, int, char, etc..
In my main I declare studentSchedule organizer;
The reason I want to know if public is okay for class type member variable is now I have access to each array variable, AND all of its functions without having to duplicate functions for each and every class.
This duplication seems really inefficient to me.
// there are comments because I am currently experimenting.
//friend class studentSchedule;
//Keep in mind each of these variables has a get, set, show function.
So why rewrite all of these functions in studentSchedule class? When even if i declare student as public in studentSchedule, you still can not directly access its members from main.
Any insight on the why they should still be private is helpful.
Thank you in advance.
is perfectly okay if the variable courses is public.
but much more tedious if it's private.
Call me the guy looking for the easy way out, but it seems less messy.