The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: MATLAB OOP: Can't we just be friends?
Replies: 2   Last Post: Jun 25, 2013 10:53 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Matt Latourette

Posts: 6
Registered: 3/11/07
MATLAB OOP: Can't we just be friends?
Posted: Mar 16, 2007 7:01 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I've been using MATLAB's object-oriented programming features to
build a set of classes to represent my data. Essentially, the way
the data is structured, many of the classes are containers that
encapsulate instances of other classes. Sometimes it would be
advantageous for the container classes to access fields of the
encapsulated objects they hold. However, they are not allowed to do
so because "access to an object's fields is only permitted within its

I could, of course, write accessor methods for each situation that
calls for a container or iterator class to access data from a
subordinate object. However, the classes are so closely related that
it is not an unreasonable thing to want to permit the container or
iterator class to have direct access to the internal fields of the
subordinate object. In the C++ world, one would make the two classes
"friends" and this would allow the access. Is there an equivalent
operation in MATLAB's class system that will permit one class to
access the fields of another class?


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.