简体   繁体   中英

How does message passing help to implement the modifier in OOP?

When one object invokes a method of another object, a message is passed which includes the name of called object, the method name and the information to transfer. But how is it determined if the calling object has privilege to access the called object's method? For example, the method is protected.

Java and C++ are compiled languages. The compiler knows the declaration of the class and decides if the caller has access to the method. If not, an error is given at compile time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM