carl.sutton Posted January 4, 2012 Posted January 4, 2012 The docs state as follows; Member Access Levels UnigineScript provides two different levels for accessing class members: public means that a member can be accessed from the outside of the class instance private means that only the class instance can accesse such member All class members are public by default. So until now I've just coped by having everything public as thats the default, but when there are no public or private keywords in UnigineScript, how do I achieve a private access level as described here?
frustum Posted January 4, 2012 Posted January 4, 2012 Unigine script has public and private keywords. The scoping works in the C++ way: class Foo { int public_i; void public_foo() { } private: int private_i; void private_foo() { } public: int public_j; void public_bar() { } };
carl.sutton Posted January 4, 2012 Author Posted January 4, 2012 Oh I see now, I was not using the correct syntax, as I was not using the access modifier in a code block with a colon, e.g. "private int someInt;" would not work. I didn't see an example of this in the docs so perhaps it would be an idea to include it?
k.shabordin Posted January 6, 2012 Posted January 6, 2012 But its not working :) class base { private: void private_f() {log.message("hello from private member!\n");} public: void public_f() {log.message("hello from public member!\n");} }; class test : base { void foo() { base::private_f(); base::public_f(); } }; test bar = new test(); bar.foo(); I see both messages in my log. Its no C++ behavior.
Guest anet Posted January 10, 2012 Posted January 10, 2012 In Unigine script private memebers are also seen inside inherited classes too.
Recommended Posts