An Introduction to Database Systenm第十七章IO流
An Introduction to Database Systems

An Introduction to Database SystemCONTENTSPART ⅠCHAPTER 1 Introduction1.1Brief introduction to database system1.1.1Data,database,database management system, database system 1.1.3Generation and development of Database Management Technology 1.1.3Characteristic of database system1.2Data Model1.2.1Two type data model1.2.2Main elements of data model1.2.3Conceptual model1.2.4Most frequently-used data model1.2.5Hierarchical model1.2.6Network model1.2.7Relational model1.3Database system structure1.3.1Concept of database system schema1.3.2 Tertiary pattern structure1.3.3 Secondary image function of database and Data independence 1.4 composition of the database systemCHAPTER 2 Relational database2.1 Relational Data structure2.1.1 relation2.1.2 relation schema2.1.3 Relational database2.2 Relational operation2.2.1Basic Relational operation2.2.2 Relational data language2.3 integrity of relation2.3.1 three types integrity constraints of relation2.3.2Entity Integrity2.3.3Referential2.3.4 User-defined Integrity2.4 Relational algebra2.4.1 traditional set operation2.4.2 special relational calculus2.5 Relational calculus2.5.1 ALPHA2.5.2 Tuple relational calculus2.5.3 QBECHAPTER 3 Relational database standard language SQL 3.1summary3.1.1 Generation and development of SQL3.1.2 Characteristics of SQL3.1.3 basic concept of of SQL3.2Student-corse database3.3 Data definition3.3.1 definition and delete of schema3.3.2 definition , delete and Modify of Basic table3.3.3 build and delete of index3.4 Data query3.4.1 Single-table queries3.4.2 Join query3.4.3 Nested queries3.4.4 Collection queries3.4.5 common form of SELECT statement3.5 Data update3,5,1 Inserting data3.5.2 Modify data3.5.3 Deleting data3.6view3.6.1 View definition3.6.2 Query view3.6.3 Update the view3.6.4view’s functionCHAPTER 4 Database security4.1 summary of computer security4.1.1three types problems of computer system4.1.2Introduction Of Safety standards4.2 Database security control4.2.1Identification&Authentication4.2.2 Access control4.2.3DAC Method4.2.4Authorization and retrieve4.2.5 Database role4.2.6MAC4.3 View mechanism4.4Audit4.5 Data encryption4.6 Statistical databases securityCHAPTER 5 Database integrity5.1 Entity integrity5.1.1 definition5.1.2 check and Default process of Entity integrity5.2 Referential integrity5.2.1 definition5.2.2 check and Default process of Referential integrity5.3 User-defined integrity5.3.1 Constraint conditions’ definition on attribute5.3.2 check and Default process of Constraint conditions on attribute 5.3.3 Constraint conditions’ definition on tuple5.3.4 check and Default process of Constraint conditions on tuple 5.4 integrity constraints Naming clause5.5 integrity constraints in the domain5.6 trigger5.6.1 define trigger5.6.2 activate trigger5.6.3 delete triggerCHAPTER 6 Relational data theory6.1 problem’s production6.2 standardization6.2.1 functionally dependant6.2.2 Code6.2.3 Normal Form6.2.4 2NF(The Second Normal Form)6.2.5 3NF(The Third Normal Form)6.2.6 BCNF6.2.7 Multivalued Dependency6.2.8 4NF6.3 axiomatics of data dependency6.4 decomposition of schemes6.4.1 three Definitions of schema decomposition6.4.2Lossless join and Keep function dependence of decomposition 6.4.3 arithmetic of schema decompositionChapter 7 database design7.1 summary7.1.1 characteristics of database design7.1.2 database design method7.1.3 basic step of database design7.1.4 all levels schema in the database design process7.2 Requirements Analysis7.2.1 Requirements Analysis’s tasks7.2.2 Requirements Analysis’s methods7.2.3 data dictionary7.3 conception structure design7.3.1 conceptual structure7.3.2 conception struct ure design’s methods and steps7.3.3 data abstraction and partial view design7.3.4 Integration views7.4 logical structure design7.4.1 converting Entity-Relationship Diagram into Relation Model7.4.2 Data model’s optimization7.4.3 design user sub-models7.5 Physical Design of database system7.5.1 Physical Design of database system ‘s contents and methods7.5.2 the choice between Relation Schema and Access Method7.5.3 ensure database’s storage structure7.5.4 Evaluation of physical structure7.6 implementing and safeguard of database7.6.1 Data loading and Application debugging7.6.2test run of database7.6.3 running and safeguard of databaseChapter 8 Database programming8.1 embedded SQL8.1.1processing procedure of embedded SQL8.1.2communication between embedded SQL statement and main language 8.1.3 SQL statement that don’t use Cursors8.1.4 SQL statement that use Cursors8.1.5 dynamic SQL8.2 Stored Procedure8.2.1PL/SQL’s block structure8.2.2 definition of variable and constant8.2.3 Control Structure8.2.4 Stored Procedure8.3ODBC programming8.3.1 summary of Database Connectivity8.3.2 summary of ODBC’s Operating Principle8.3.3 ODBC API foundation8.3.4ODBC’s WorkflowChaper 9 relational query Processing and query optimization9.1 query Processing of relational database system9.1.1steps of query Processing9.1.2 algorithm example of Implementing query operation9.2 query optimization of relational database system9.2.1summary of query optimization9.2.2 an example9.3 Algebra optimization9.3.1Relational algebra expression equivalence transformation rules 9.3.2Query Tree’s heuristic optimization9.4 Physics optimization9.4.1 heuristic rule-based access path optimization9.4.2 cost-based optimizationCHAPTER 10 Database recovery techniques10.1 The basic concept of Transaction10.2 Database recovery overview10.3 Fault types10.4 implementation techniques of Recovery10.4.1 Data dump10.4.2 Registry logging10.5 Recovery policy10.5.1 Recovery of Transaction failure10.5.2 Recovery of System fault10.5.3 Recovery of medium failure10.6 recovery technology with Checkpoint10.7database mirrorCHAPTER 11 Concurrency control11.1 Summary of Concurrency control11.2Locking11.3 livelock and deadlock11.3.1 livelock11.3.2 deadlock11.4 serializability of Concurrent schedules11.4.1 Serializable schedules11.4.2 Conflict serializable schedules11.5 Two phase locking protocol11.6 Granularity of blockade11.6.1 Multi-granularity blockade11.6.2 Intent locksCHAPTER 12 Database management system(DBMS)12.1 Basic function of DBMS12.2 Process structure and Multi thread mechanism of DBMS 12.2.1 N Scheme: integrating DBMS with Application12.2.2 2N Scheme:12.2.3 N+1 Scheme:12.2.4 N+M Scheme12.2.5 Concept of Multi_Threaded of DBMS12.3 DBMS System structure12.3.1 Hierarchical structure of DBMS12.3.2 example of RDBMS’s Operation process12.4Language processing12.4.1Task and work steps of Language processing layer12.4.2Interpretation method12.4.3 Pre compilation methodCHAPTER 13 New Development of database technology13.1 Summary13.2Three Stage of Development of database13.2.1 First generation database system13.2.2 The second generation database system13.2.3The third generation database system13.3 development Characteristics of database system13.3.1 development of Data model13.2.2 combining Database technology with other technology13.3.3New Database technology that face Application field13.4 Development trend of database technologyCHAPTER 14 Distributed Database System14.1 Summary(概述)14.1.1 Distributed Database System14.1.2 The characteristics of distributed database system14.2 The System structure of distributed database system14.2.1 The Mode structure of distributed database system14.2.2 Data slice14.2.3 Distributed transparency14.2.4 Distributed database management system14.3 Query processing and optimization14.3.1 an example14.3.2 problems need to solve of Query processing and optimization 14.3.3 aim of Query optimization14.3.4 optimization of Join query14.4 Distributed transaction management14.4.1 recovery of Distributed transaction14.4.2 Concurrency controlCHAPTER 15 Object relational database system15.1 Object oriented data model15.1.1 The core concept of OO Model15.1.2Class hierarchy15.1.3Inheritance15.1.4The nested objects15.2Object- relational database15.2.1Extended relational data type in the Object relational database system15.2.2Extended Object type in the Object relational database system and it’s definition 15.2.3Reference type15.2.4Inheritance15.2.5child table and Super TableCHAPTER 16 XML(Extensible Markup Language)Database16.1 Brief introduction16.2 Brief introduction to XML16.3 XML Data model16.3.1 XML DTD16.3.2 XML Schema16.4 SQL/XML16.4.1 XML Data type16.4.2 XML Release function16.4.3 XML Extraction functionCHAPTER 17 Data warehouse and OLAP Technology17.1 Data warehouse Technology17.2 On_Line Analytical Processing technology17.3 Data mining technology。
第七章数据库设计(续2)

转换内容
将E-R图转换为关系模型:将实体、实体的属性和 实体之间的联系转换为关系模式。
An Introduction to Database Systemቤተ መጻሕፍቲ ባይዱ
E-R图向关系模型的转换(续) 图向关系模型的转换( 图向关系模型的转换
逻辑结构设计小结
优化数据模型的方法
1. 确定数据依赖 2. 对于各个关系模式之间的数据依赖进行极小化处理, 消除冗余的联系。 3. 确定各关系模式分别属于第几范式。 4. 分析对于应用环境这些模式是否合适,确定是否要对 它们进行合并或分解。 5. 对关系模式进行必要的分解或合并
An Introduction to Database System
An Introduction to Database System
E-R图向关系模型的转换(续) 图向关系模型的转换( 图向关系模型的转换
[例] 把图7.30中虚线上部的E-R图转换为关系模型(续)
联系“参加”所对应的关系模式 职工工作(职工号,产品号,工作天数,…) 联系“供应”所对应的关系模式 供应(产品号,供应商号,零件号,供应量)
按照数据依赖的理论对关系模式逐一进行分析 考查是否存在部分函数依赖、传递函数依赖、多值依赖等 确定各关系模式分别属于第几范式
An Introduction to Database System
数据模型的优化( 数据模型的优化(续)
4. 按照需求分析阶段得到的各种应用对数据处理的要求, 分析对于这样的应用环境这些模式是否合适, 确定是否要对它们进行合并或分解。
An Introduction to Database System
最新关系代数表达式

课程名 Cname 数据库
数学 信息系统 操作系统 数据结构 数据处理 PASCAL语言
(b)
先行课 Cpno5Biblioteka 学分 Ccredit4
2
1
4
6
3
7
4
2
6
4
An Introduction to Database System
SC
学号 Sno 200215121
200215121
200215121 200215122
学号 Sno 200215121
200215122
200215123
200215125
姓名 Sname
李勇
刘晨
王敏
张立
性别 Ssex
男 女 女 男
(a)
年龄 Sage
20
所在系 Sdept
CS
19
IS
18
MA
19
IS
An Introduction to Database System
Course
课程号 Cno 1 2 3 4 5 6 7
❖2. “出得去,回得来”
❖ 将人眼的移动过程翻译成关系代数表达式。(利 用对于学过的关系代数理论的理解)
❖ 人眼纵向扫描满足条件的元组——选择σ ❖人眼定位到某个元组后选择某些属性列的值—
—投影π
An Introduction to Database System
查询选修了2号课程的学生的学号。 πSno(σCno=‘2’(SC)) 查询至少选修1号课程和3号课程的学生号码
200215122
课程号 Cno 1
2
3 2
3
成绩 Grade
数据库系统概论(第四版)_王珊萨师煊chp7-2

数据抽象
抽象是对实际的人、物、事和概念中抽取所 关心的共同特性,忽略非本质的细节,并把 这些特性用各种概念精确地加以描述。
概念结构是对现实世界的一种抽象
An Introduction to Database System
数据抽象(续)
三种常用抽象
1. 分类(Classification)
视图的集成(续)
逐步集成
用累加的方式一次集成两个分E-R图
An Introduction to Database System
视图的集成(续)
集成局部E-R图的步骤
1. 合并 2. 修改与重构
An Introduction to Database System
视图的集成(续)
An视图集成 to Database Introduction System
逐一设计分E-R图(续)
分E-R图的框架
An Introduction to Database System
逐一设计分E-R图(续)
参照第二层数据流图和数据字典,遵循两个准则,进
行如下调整:
(1) 订单与订单细节是1∶n的联系 (2) 原订单和产品的联系实际上是订单细节和产品的联 系。 (3) 图7.21中“发票主清单”是一个数据存储,不必 作为实体加入分E-R图
概念结构(续)
描述概念模型的工具
E-R模型
An Introduction to Database System
7.3 概念结构设计
7.3.1 概念结构
7.3.2 概念结构设计的方法与步骤 7.3.3 数据抽象与局部视图设计 7.3.4 视图的集成
An Introduction to Database System
数据库系统概论AnIntroductiontoDatabaseSystems

3.重复第二步,直到不再有其他的属性加入到X。(因X的元素只能增 长,而关系模式中属性都是有限的,最后肯定存在不能再加入情况。)
当不能添加任何属性时,集合X就是{A1,A2,…,An}+。 例 :考虑含有属性A,B,C,D,E,F的关系,设关系有FD:AB→C, BC→AD, D→E, CF→B,则{A,B}的闭包{A,B}+是什么?
An Introduction to Database Systems
分解/结合规则
如果属性集A1,A2,…,An函数决定多个属性,即 A1A2…An→B1,A1A2…An→B2, …,A1A2…An→Bm 则这个FD集合可缩写为: A1A2…An→B1B2Bm 分解规则(splitting rule)
函数依赖的类型 平凡的: Y X 非平凡的: Y 中至少有一个属性不属于X 完全非平凡的: Y中所有属性均不属于X
An Introduction to Database Systems
完全函数依赖与部分函数依赖
定义6.2 在R(U)中,如果X→Y,并且对于X的任何一个真
子集X’,都有X’
Y, 则称Y对X完全函数依赖,记作
应用需求 (数据、处理) 转换规则 按 DBMS 要求
需求收集和分析
设计概念结构
设计逻辑结构
应用要求 DBMS 详细特征
不满意
数据模型优化
设计物理结构
评价设计、性能预测 不满意 物理实现
试验性运行 不满意
数 据 库 设 计 的 基 本 n to Database Systems
2、一个系只有一名(正职)负责人—系主任。 3、一个学生可选多门课程,每门课程有若干学生选修。 4、每个学生选每门课有一个成绩。
数据库系统概论精品电子教案完美版

数据的形式
数据的特点
数据的数字化
数字化是指把数据转化为0和1表示的二进制码。
数据是数据库中存储的基本对象
6
2018/5/14
二、数据库
数据库(Database,简称DB)是存放 数据的仓库,该仓库位于计算机存储设 备上,数据按一定结构存放。
2018/5/14
7
三、数据库管理系统
数据库管理系统
2018/5/14
13
一、人工管理
时期
40年代中--50年代中
产生的背景
应用需求 硬件水平 软件水平 处理方式
科学计算 无直接存取存储设备 没有操作系统 批处理
2018/5/14
14
人工管理(续)
特点
数据不保存 数据不共享 数据不具有独立性
2018/5/14
15
应用程序与数据的对应关系(人工管理)
数据库
2018/5/14
11
1.1 数据库系统概述
1.1.1 四个基本概念
1.1.2 数据管理技术的产生与发展
2018/5/14
12
1.1.2 数据管理技术的产生和发展
数据管理技术的发展过程
人工管理阶段(40年代中--50年代中)
文件系统阶段(50年代末--60年代中)
数据库阶段(60年代末--现在)
数据库系统概论
An Introduction to Database System
2018/5/14
2018年5月
1
数据库技术应用十分广泛
教学管理系统 图书馆管理系统 工厂、商场、酒店、医院、社区管理系统 各类网站、Web应用等等。
数据库系统概念(database system concepts)英文第六版 PPT 第17章

Database System Concepts - 6th Edition
17.3
© Silberschatz, Korth and Sudarshan
A Centralized Computer System
Database System Concepts - 6th Edition
17.4
© Silberschatz, Korth and Sudarshan
computer systems.
General-purpose computer system: one to a few CPUs and a number
of device controllers that are connected through a common bus that provides access to shared memory.
Checkpoint process
Performs periodic checkpoints
Monitors other processes, and takes recovery actions if any of the other processes fail
Process monitor process
Chapter 17: Database System Architectures
Centralized and Client-Server Systems Server System Architectures Parallel Systems Distributed Systems
better functionality for the cost flexibility in locating resources and expanding facilities better user interfaces easier maintenance
An Introduction to Database System

Homeworks
Some paper-based, some may involve light programming No late homework will be accepted Project Select an application that needs a database Build a database application from start to finish Significant amount of programming Will be done in stages you will submit some work at the end of each stage
Grading Breakdown
Homework: 10% Class:10% Project: 10% Final: 70%
The content of the course
基础篇
第一章:绪论(Introduction) 第二章:关系数据库(Relational Database) 第三章:关系数据库标准语言SQL( Structured Query Language) 第四章:数据库安全性(Database Safety) 第五章:数据库完整性(Database Integrity)
accountnumber A-101 A-215 A-201 A-217 A-201
A Sample Relational Database
EntityEntity-Relationship Model
Entity Sets Relationship Sets Design Issues Mapping Constraints Keys E-R Diagram Extended E-R Features Design of an E-R Database Schema Reduction of an E-R Schema to Tables
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
原理( 2. 原理(续2)
(2)cin是istream的全局对象,istream流类也有 cin是istream的全局对象,istream流类也有 的全局对象 若干个友元: 若干个友元:
istream& operator<<(ostream&dest,char*pSource); istream& operator<<(ostream&dest,int source); istream& operator<<(ostream&dest,char source); //等等 //等等
表17_2 文件打开选择项
标志 ios::ate ios::in ios::out ios::trunc ios::nocreate ios::noreplace ios::binary 含义 如果文件存在, 如果文件存在,输出内容加在末尾 具有输入能力(ifstream默认) 具有输入能力(ifstream默认) 默认 具有输出能力(ofstream默认) 具有输出能力(ofstream默认) 默认 如果文件存在,清除文件内容(默认) 如果文件存在,清除文件内容(默认) 如果文件不存在, 如果文件不存在,返回错误 如果文件存在, 如果文件存在,返回错误 以二进制方式打开文件
原理( 2. 原理(续1)
cout<<”My Jone”; 例:cout<< My name is Jone ; 说明:cout是ostream对象 <<是操作符 对象, 是操作符, 说明:cout是ostream对象,<<是操作符,右面是 char*类型 故匹配上面的“ 类型, char*类型,故匹配上面的“ostream& Operator<<(ostream&dest,char*pSource);”操作 Operator<<(ostream&dest,char*pSource);”操作 它将整个字串输出,并返回ostream ostream流对象的 符。它将整个字串输出,并返回ostream流对象的 引用。 引用。
例:在除法操作不能进行时显示一条错误信息。 在除法操作不能进行时显示一条错误信息。
//ch19_1.cpp #include<iostream.h> void fn(int a,int b) cerr<<”zero encountered.”<< <<”The {if(b==0) cerr<< zero encountered. << The message redirected”; cannot be redirected ; else cout<<a/b<<endl; } void main() {fn(20,2); fn(20,0); } 结果: 结果: 10 zero encountered.The message cannot be redirected
I/O流 第十七章 I/O流
17.1 17.2 17.3 17.4 17.5 17.6 printf和scanf的缺陷 printf和scanf的缺陷 I/O标准流类 I/O标准流类 文件流类 串流类 控制符 使用I/O I/O成员函数 使用I/O成员函数
printf和scanf的缺陷 17.1 printf和scanf的缺陷
文件流类( 17.3 文件流类(续1)
说明: 说明:
(4)类ofstream用于执行文件输出,该类有几个构造函 ofstream用于执行文件输出, 用于执行文件输出 其中最有用的是: 数,其中最有用的是: ofstream::ofstream(char* pFileName, //指向要打开的文件名字串 //指向要打开的文件名字串 //打开方式 int mode=ios::out, //打开方式 //保护方式 int prot=filebuf::openprot); //保护方式 mode是打开方式 它的选择项见表17_2 是打开方式, 17_2。 (5)mode是打开方式,它的选择项见表17_2。 prot是保护方式 它的选择项见表17_3 是保护方式, 17_3。 prot是保护方式,它的选择项见表17_3。
I/O流 第十七章 I/O流
17.1 17.2 17.3 17.4 17.5 17.6 printf和scanf的缺陷 printf和scanf的缺陷 I/O标准流类 I/O标准流类 文件流类 串流类 控制符 使用I/O I/O成员函数 使用I/O成员函数
17.3 文件流类
说明: 说明: ofstream,ifstream,fstream是文件流类 是文件流类, (1)ofstream,ifstream,fstream是文件流类, fstream.h中定义 其中,fstream是 中定义。 在fstream.h中定义。其中,fstream是ofstream ifstream多重继承的子类 多重继承的子类。 和ifstream多重继承的子类。 文件流类不是标准设备, (2)文件流类不是标准设备,没有预先定义的全 局对象。文件流类定义的操作应用于外部设备, 局对象。文件流类定义的操作应用于外部设备, 最典型的设备是磁盘中的文件。 最典型的设备是磁盘中的文件。 文件名和 定义一个文件流类对象,包括文件名 (3)定义一个文件流类对象,包括文件名和打开 方式。 方式。
串流类( 17.4 串流类(续1)
说明: 说明: istrstream用于执行串流输入 用于执行串流输入, (4)类istrstream用于执行串流输入,该类有几 个构造函数,其中最有用的是: 个构造函数,其中最有用的是:
C++名字 C++名字 cin cout cerr clog 设备 键盘 屏幕 屏幕 打印机 C中的名字 stdin stdout stderr stdprn 默认的含义 标准输入 标准输出 标准错误 打印机
2. 原理
(1)cout是ostream流类的对象,它在iostream.h cout是ostream流类的对象,它在iostream.h 流类的对象 头文件中作为全局对象定义: 头文件中作为全局对象定义:
I/O流 第十七章 I/O流
17.1 17.2 17.3 17.4 17.5 17.6 printf和scanf的缺陷 printf和scanf的缺陷 I/O标准流类 I/O标准流类 文件流类 串流类 控制符 使用I/O I/O成员函数 使用I/O成员函数
17.4 串流类
说明: 说明: ostrstream,istrstream,strstream是串流 (1)ostrstream,istrstream,strstream是串流 strstream.h中定义 其中,strstream是 中定义。 类,在strstream.h中定义。其中,strstream是 ostrstream和istrstream多重继承的子类 多重继承的子类。 ostrstream和istrstream多重继承的子类。 串流类不是标准设备, (2)串流类不是标准设备,没有预先定义的全局 对象。串流类允许将fstream fstream类定义的文件操作应 对象。串流类允许将fstream类定义的文件操作应 用于存储区中的字符串,即将字符串看作为设备。 用于存储区中的字符串,即将字符串看作为设备。 定义一个串流类对象, (3)定义一个串流类对象,包括字符数组和数组 大小。 大小。
//ch19_2.cpp #include<fstream.h> void fn() myf(“c: bctemp\ myname”); c:\ {ofstream myf( c:\\bctemp\\myname ); myf<<”In myf<< In each of the following questions, pair\ a related pair\n” <<“of << of words or phrases is pairs\ followed by five lettered pairs\n” <<”of phrases.\ ; << of words or phrases.\n”; } void m
17.1 17.2 17.3 17.4 17.5 17.6 printf和scanf的缺陷 printf和scanf的缺陷 I/O标准流类 I/O标准流类 文件流类 串流类 控制符 使用I/O I/O成员函数 使用I/O成员函数
I/O标准流类 17.2 I/O标准流类
主要内容: 主要内容:
1.标准流的设备名 2.原理
1.标准流的设备名
iostream.h是I/O流的标准头文件。 iostream.h是I/O流的标准头文件。其对应的标准设备 流的标准头文件 见表19 19表明:cout对象的默认输出是屏幕,cin对 对象的默认输出是屏幕 见表19-1。表明:cout对象的默认输出是屏幕,cin对 键盘。 象的默认输入是键盘 象的默认输入是键盘。 19- 标准I/O I/O流设备 表19-1 标准I/O流设备
原理( 2. 原理(续3)
( 3 ) 除了标准输入输出设备,还有标准错误设备 除了标准输入输出设备, cerr。当程序测试并处理关键错误时, cerr。当程序测试并处理关键错误时,不希望程序 的错误信息从屏幕显示重定向到其它地方, 重定向到其它地方 的错误信息从屏幕显示重定向到其它地方,这时使 cerr流显示信息 流显示信息。 用cerr流显示信息。
文件流类( 17.3 文件流类(续2)
说明: 说明: 打开方式默认为ios::out|ios::trunc ios::out|ios::trunc, 打开方式默认为ios::out|ios::trunc,即该文件 用于接受程序的输出,如果该文件原先已存在, 用于接受程序的输出,如果该文件原先已存在, 则其内容必须先清除,否则就新建。 则其内容必须先清除,否则就新建。 ifstream打开的文件 打开的文件, 用ifstream打开的文件,默认打开方式为 ios::in, ofstream打开的文件 打开的文件, ios::in,用ofstream打开的文件,打开方式不能 默认。 默认。