当前位置: 首页 > news >正文

有哪些做网站好的公司seo排名赚下载

有哪些做网站好的公司,seo排名赚下载,Wordpress淘客自动采集,住房和城乡建设部注册中心之前一直不明白说的C 中的头文件到底是什么东西&#xff0c; 经过学习&#xff0c;我自己理解为&#xff1a;C头文件也就是相等与 C#中的“类” 的概念吧。 使用书中提供的Sales_item.h头文件&#xff0c;实现计算“书”的价格计算。 代码如下&#xff1a; #include <iostre…

之前一直不明白说的C++ 中的头文件到底是什么东西,

经过学习,我自己理解为:C++头文件也就是相等与 C#中的“类” 的概念吧。

使用书中提供的Sales_item.h头文件,实现计算“书”的价格计算。

代码如下:

#include <iostream>
#include "Sales_item.h"int main()
{Sales_item book;std::cin >> book;std::cout << book << std::endl;return 0;
}

  

头文件代码:

/*
* This file contains code from "C++ Primer, Fourth Edition", by Stanley B.
* Lippman, Jose Lajoie, and Barbara E. Moo, and is covered under the
* copyright and warranty notices given in that book:
*
* "Copyright (c) 2005 by Objectwrite, Inc., Jose Lajoie, and Barbara E. Moo."
*
*
* "The authors and publisher have taken care in the preparation of this book,
* but make no expressed or implied warranty of any kind and assume no
* responsibility for errors or omissions. No liability is assumed for
* incidental or consequential damages in connection with or arising out of the
* use of the information or programs contained herein."
*
* Permission is granted for this code to be used for educational purposes in
* association with the book, given proper citation if and when posted or
* reproduced.Any commercial use of this code requires the explicit written
* permission of the publisher, Addison-Wesley Professional, a division of
* Pearson Education, Inc. Send your request for permission, stating clearly
* what code you would like to use, and in what specific way, to the following
* address:
*
* Pearson Education, Inc.
* Rights and Contracts Department
* 75 Arlington Street, Suite 300
* Boston, MA 02216
* Fax: (617) 848-7047
*/
#ifndef SALESITEM_H
#define SALESITEM_H
// Definition of Sales_item class and related functions goes here

#include <iostream>
#include <string>
class Sales_item {
friend bool operator==(const Sales_item&, const Sales_item&);
// other members as before
public:
// added constructors to initialize from a string or an istream
Sales_item(const std::string &book):
isbn(book), units_sold(0), revenue(0.0) { }
Sales_item(std::istream &is) { is >> *this; }
friend std::istream& operator>>(std::istream&, Sales_item&);
friend std::ostream& operator<<(std::ostream&, const Sales_item&);
public:
// operations on Sales_item objects
// member binary operator: left-hand operand bound to implicit this pointer
Sales_item& operator+=(const Sales_item&);
// other members as before

public:
// operations on Sales_item objects
double avg_price() const;
bool same_isbn(const Sales_item &rhs) const
{ return isbn == rhs.isbn; }
// default constructor needed to initialize members of built-in type
Sales_item(): units_sold(0), revenue(0.0) { }
// private members as before
private:
std::string isbn;
unsigned units_sold;
double revenue;
};

// nonmember binary operator: must declare a parameter for each operand
Sales_item operator+(const Sales_item&, const Sales_item&);
inline bool
operator==(const Sales_item &lhs, const Sales_item &rhs)
{
// must be made a friend of Sales_item
return lhs.units_sold == rhs.units_sold &&
lhs.revenue == rhs.revenue &&
lhs.same_isbn(rhs);
}
inline bool
operator!=(const Sales_item &lhs, const Sales_item &rhs)
{
return !(lhs == rhs); // != defined in terms of operator==
}
using std::istream; using std::ostream;
// assumes that both objects refer to the same isbn
inline
Sales_item& Sales_item::operator+=(const Sales_item& rhs)
{
units_sold += rhs.units_sold;
revenue += rhs.revenue;
return *this;
}
// assumes that both objects refer to the same isbn
inline
Sales_item
operator+(const Sales_item& lhs, const Sales_item& rhs)
{
Sales_item ret(lhs); // copy lhs into a local object that we'll return
ret += rhs; // add in the contents of rhs
return ret; // return ret by value
}
inline
istream&
operator>>(istream& in, Sales_item& s)
{
double price;
in >> s.isbn >> s.units_sold >> price;
// check that the inputs succeeded
if (in)
s.revenue = s.units_sold * price;
else
s = Sales_item(); // input failed: reset object to default state
return in;
}
inline
ostream&
operator<<(ostream& out, const Sales_item& s)
{
out << s.isbn << "\t" << s.units_sold << "\t"
<< s.revenue << "\t" << s.avg_price();
return out;
}
inline
double Sales_item::avg_price() const
{
if (units_sold)
return revenue/units_sold;
else
return 0;
}

#endif

 

执行截图:


这里表示4本书的单价是 24.99元。

打印出来后得到4本的总收入99.96元 单价为 24.99元

参考:http://www.wxzzz.com/?id=74

 

转载于:https://www.cnblogs.com/andrew-blog/archive/2011/12/11/C_Class_Include.html

http://www.lbrq.cn/news/2513881.html

相关文章:

  • wordpress网站底部导航代码培训心得总结怎么写
  • 如何开发手机版网站百度排行榜
  • 大淘客官网做的网站打不开金昌网站seo
  • 国外用tornado做的网站seo推广视频隐迅推专业
  • 建网站教程如何免费创建自己的平台
  • 网站建设图片怎么做合肥做网站哪家好
  • 专业网站的建设品牌营销推广
  • 长沙设计网站排名域名查询官网
  • 网站开发 安全合同seo网络优化前景怎么样
  • 台州网络建站模板平面设计培训
  • 鄂州网站制作哪家好广州百度seo优化排名
  • 英铭网站建设网站推广广告
  • web网站开发标题字体加粗百度快速收录工具
  • 网站建设分配人员方案营业推广是什么意思
  • 做网站都要买服务器吗广告网
  • 运维难还是开发难免费网站seo诊断
  • 有没有做海报的网站推荐泉州seo优化
  • 建材建设网站google海外版
  • php站点搭建短视频推广app
  • 上海建设网站定做网站创建的流程是什么
  • 在线网站设计关键词分布中对seo有危害的
  • 合肥做网站价格北京seo优化排名
  • 牛b插网站建设网站推广计划方案
  • 专业的网页设计和网站制作公司凡科建站官网免费注册
  • 黄骅海边旅游景区推广关键词优化
  • 在线网站建设培训免费推广网站大全下载
  • 好看的网站页面设计seocms
  • 长沙做个网站多少钱域名关键词查询
  • 礼品网站建设平台推广引流
  • 网站权重什么意思站长工具排行榜
  • EnergyMath芯详科技 EMS4100/MES4000/MES3900
  • Apache Ignite 的分布式原子类型(Atomic Types)
  • 在CSS中,如果你想设置一个元素的高度(height)与其宽度(width)相匹配,但又希望宽度使用百分比来定义,你可以通过几种方式来实现。
  • Golang语言如何高效使用字符串
  • Python动态规划:从基础到高阶优化的全面指南
  • 屏幕晃动机cad【4张】三维图+设计说明书