From what I understand in the proper way, we need to create this path in order to be able to use the variable in private, but I just can't wrap my head around how the public functions work and why they're needed. I just can't connect the dots as to how they make it possible for the code in main to get to the variable. Can somebody please help me?
class what{
int x;
public:
int getx(){
return x;
}
}
The function here is public so you have an acess to it from main and it return x the private var, but the function is also a part of "what" so it possible to function to get a private variable inside the class