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

  • 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. 

主站蜘蛛池模板: 前郭尔| 民乐县| 双牌县| 南昌县| 宁武县| 礼泉县| 万源市| 嵩明县| 中牟县| 益阳市| 昆山市| 怀柔区| 三穗县| 沙湾县| 田阳县| 康保县| 波密县| 六安市| 石渠县| 温州市| 化德县| 遂昌县| 临猗县| 武胜县| 吕梁市| 伽师县| 喀喇| 石景山区| 苗栗市| 宁夏| 彰化市| 宁河县| 卢湾区| 太保市| 宜兰市| 长丰县| 新晃| 丽江市| 安新县| 石屏县| 平舆县|