1. 首页
  2. 编程语言
  3. C++ 
  4. C++ Primer4[TXT]版

C++ Primer4[TXT]版

上传者: 2021-03-11 21:08:35上传 RAR文件 749.09KB 热度 28次
This chapter introduces most of the basic elements of C++: built-in, library, and class types; variables; expressions; statements; and functions. Along the way, we'll briefly explain how to compile and execute a program. 本章介绍 C++ 的大部分基本要素:内置类型、库类型、类类型、变量、表达式、语句和函数。在这一过程中还会简要说明如何编译和运行程序。 Having read this chapter and worked through the exercises, the reader should be able to write, compile, and execute simple programs. Subsequent chapters will explain in more detail the topics introduced here. 读者读完本章内容并做完练习,就应该可以编写、编译和执行简单的程序。后面的章节会进一步阐明本章所介绍的主题。 Learning a new programming language requires writing programs. In this chapter, we'll write a program to solve a simple problem that represents a common data-processing task: A bookstore keeps a file of transactions, each of which records the sale of a given book. Each transaction contains an ISBN (International Standard Book Number, a unique identifier assigned to most books published throughout the world), the number of copies sold, and the price at which each copy was sold. Each transaction looks like 要学会一门新的程序语言,必须实际动手编写程序。在这一章,我们将缩写程序解决一个简单的数据处理问题:某书店以文件形式保存其每一笔交易。每一笔交易记录某本书的销售情况,含有 ISBN(国际标准书号,世界上每种图书的唯一标识符)、销售册数和销售单价。每一笔交易形如: 0-201-70353-X 4 24.99 where the first element is the ISBN, the second is the number of books sold, and the last is the sales price. Periodically the bookstore owner reads this file and computes the number of copies of each title sold, the total revenue from that book, and the average sales price. We want to supply a program do these computations. 第一个元素是 ISBN,第二个元素是销售的册数,最后是销售单价。店主定期地查看这个文件,统计每本书的销售册数、总销售收入以及平均售价。我们要编写程序来进行这些计算。 Before we can write this program we need to know some basic features of C++. At a minimum we'll need to know how to write, compile, and execute a simple program. What must this program do? Although we have not yet designed our solution, we know that the program must 在编写这个程序之前,必须知道 C++ 的一些基本特征。至少我们要知道怎么样编写、编译和执行简单的程序。这个程序要做什么呢?虽然还没有设计解决方案,但是我们知道程序必须: Define variables 定义变
用户评论