访问者与公共成员 [英] Accessors vs. public members

查看:82
本文介绍了访问者与公共成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类有许多内置类型成员具有读/写访问权限。我应该让他们成为公共成员,并为每个人提供get / set方法吗?如果有 rel =nofollow noreferrer>不变式,您需要保留,然后是。否则,不要打扰。


I have a class with a lot of built-in type members with read/write access. Should I make them public members and provide get/set methods for each one? How about structures?

解决方案

If there are invariants you need to preserve, then yes. Otherwise, don't bother.

这篇关于访问者与公共成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆