Public - Private.

BlitzMax Forums/BlitzMax Beginners Area/Public - Private.

Yue(Posted 2015) [#1]
I totally immersed in learning object-oriented programming. But I can not understand the words "Public" and "Private", I think they are equal to "Local" or "Global", someone can help me.

I always emphasize that I speak English and use google translator and many concepts escape me. Thank a simple example.


Yasha(Posted 2015) [#2]
Public and Private are only relevant in BlitzMax if you are using Import. They do something completely different in other languages.

Private makes any declarations below it - types, functions, and globals - invisible to code that Imports the file. It stands on a line on its own, and affects the lines that follow. You use this to hide details of how your module works from the users (so that they don't touch things that they could break).

Public makes any declarations below it visible to code that Imports the file. Since this is the default, you only need to do this if you want to undo the effect of a previous Private declaration.

Private helps provide the OOP concept of "encapsulation", but it's a bit limited in BlitzMax. BlitzMax code generally doesn't care very much about encapsulation.

You should learn to use this feature, because in other languages encapsulation is used all the time. The BlitzMax version is very simple compared to most languages though, so it will only introduce the basic concept - the usage is very different.


Yue(Posted 2015) [#3]
Thanks You.

Fails to understand all this, looking for relevant information in other languages and your explanation is obviously quite different.


Wiebo(Posted 2015) [#4]
It also helps to read the documentation.


Yue(Posted 2015) [#5]
@Wiebo
Did not speak English, I use the translator and I think the easiest way is to post my questions in these forums. Are not they for that purpose ?.


Brucey(Posted 2015) [#6]
It also helps to read the documentation.

Yes, it wouldn't be so bad if everyone spoke English natively :-p