|
-
March 1st, 2013, 10:56 AM
#2
Re: General Object-Orientated Question
#3 is the best design. Basically you want to hide the implementation and rely on an interface to access the object's data. That way you can change the implementation of the class without changing how it's used. It's also generally safer not to access an object's member variables directly. For example, if days had a limit of way 365, you wouldn't want to allow a user to set days to an invalid value. Your SetDays method could control what values days contains and set the days and years appropriately.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|