⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bundle.cpp.html

📁 《Big C++ 》Third Edition电子书和代码全集-Part1
💻 HTML
字号:
<html>

<head>
	<title>bundle.cpp</title>
</head>

<body>
<pre>  1  #include "bundle.h"
  2  
  3  void Bundle::add(Item* it)
  4  {
  5     items.push_back(it);
  6  }
  7  
  8  double Bundle::get_unit_price() const
  9  {
 10     double price = 0;
 11     for (int i = 0; i &lt; items.size(); i++)
 12     {
 13        price = price
 14           + items[i]-&gt;get_unit_price() * items[i]-&gt;get_quantity();
 15     }
 16     return price;
 17  }
 18  
 19  string Bundle::get_description() const
 20  {
 21     string description = "";
 22     for (int i = 0; i &lt; items.size(); i++)
 23     {
 24        if (i &gt; 0) description = description + ", ";
 25        description = description + items[i]-&gt;get_description();
 26     }
 27     return description;
 28  }
 29  
 30  int Bundle::get_quantity() const
 31  {
 32     return 1;
 33  }
 34  
 35  </pre>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -