>> You Wrote:
>> I have a class which creates data structure (let it be a list) as part
>> of its data. So it is a private member. I would like to "give" this list
>>to outside world. How should I implement this??
I would suggest you rethink your design. You are violating the whole purpose
of OOP and data hiding. Objects are to manipulate their own data, and hide
it from the outside world. Without knowing all of what you are doing. If you
want to be consistent with OOP, I would suggest one of two ways.
1) Have the outside world create a list and you pass a reference to this
list to your class and let your class operate on it directly.
2) Create method(s) in your class that allows the outside world to iterate
thru the items on your class internal list. Such as some get method or
getNext method.
As for making a member variable public and exposing it to the world, would
violate the whole principle of OOP. Especially because the outside world
would be able to change the list outside of your class. Which defeats the
whole purpose. I personally would do the second suggestion.
-Adam Jones
|