colobot-data/help/cbot/E/private.txt

22 lines
691 B
Plaintext
Raw Normal View History

\b;Instruction \c;private\n; (for specialists)
2016-09-10 14:09:04 +00:00
This is an access modifier for \l;class\u cbot\class; members. Private members are not accessible outside of the class definition.
\t;Example
\c;
\s;public class MyClass
\s;{
2015-05-14 21:03:03 +00:00
\s; int b; // public by default
\s; public int a; // also public
\s; private point position; // private
\s;}
\s;void Test()
\s;{
\s; MyClass item;
\s; item.a = item.b = 12; // ok
\s; message( item.position ); // this is an error
\s;}
\n;
\t;See also
2016-09-10 14:09:04 +00:00
\c;\l;class\u cbot\class;\n;, \c;\l;public\u cbot\public;\n;, \c;\l;protected\u cbot\protected;\n;
\l;Programming\u cbot;, \l;types\u cbot\type; and \l;categories\u cbot\category;.