Archived

This topic is now archived and is closed to further replies.

In General: member functions public vars private?

This topic is 5828 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Only declare member functions that will be called outside your class as public. For any member functions that will only used internally by your class declare as private.

All member variables should be declared as private. If those outside your class need to have access to certain variables then create public accessor functions (Get/Set functions) as needed for those variables. You can inline those accessors for classes where speed is critical.

This is the general accepted way to create classes and is called black-boxing.


- Houdini

Share this post


Link to post
Share on other sites
quote:
Original post by Houdini
All member variables should be declared as private.


Not everyone programs with this as a rigid rule, but in general you should make properties private



Magmai Kai Holmlor

"Oh, like you''ve never written buggy code" - Lee

"What I see is a system that _could do anything - but currently does nothing !" - Anonymous CEO

Share this post


Link to post
Share on other sites