官术网_书友最值得收藏!

  • Expert C++
  • Vardan Grigoryan Shunguang Wu
  • 133字
  • 2021-06-24 16:34:00

State

Each object has a state that may or may not differ from the state of other objects. We've already introduced the Product struct, which represents an abstraction of a physical (or digital) product. All the members of a product object collectively represent the state of the object. For example, the Product contains members such as available, which is a Boolean; it equals true if the product is in stock. The values of the member variables define the state of the object. If you assign new values to the object member, its state will change:

Product cpp_book; // declaring the object
...
// changing the state of the object cpp_book
cpp_book.available = true;
cpp_book.rating = 5;

The state of the object is the combination of all of its properties and values. 

主站蜘蛛池模板: 景谷| 霍山县| 增城市| 潼关县| 逊克县| 长兴县| 汉沽区| 大新县| 扎囊县| 嵊州市| 曲靖市| 彝良县| 安福县| 柯坪县| 德格县| 珲春市| 永丰县| 日土县| 绥芬河市| 吐鲁番市| 广河县| 万宁市| 当雄县| 个旧市| 静宁县| 紫云| 同心县| 聂拉木县| 梓潼县| 九龙县| 休宁县| 天峨县| 武鸣县| 红安县| 泗洪县| 庄河市| 延寿县| 祁连县| 睢宁县| 天柱县| 应用必备|