What is a stream in C++?(什么是 C++ 中的流?)
问题描述
我听说过流,更具体地说是文件流.
I have been hearing about streams, more specifically file streams.
那么它们是什么?
它是否在内存中有一个位置?
Is it something that has a location in the memory?
它是包含数据的东西吗?
Is it something that contains data?
它只是文件和对象之间的连接吗?
Is it just a connection between a file and an object?
推荐答案
术语流是一种构造的抽象,它允许您发送或接收未知数量的字节.比喻是水流.您可以随时获取数据,或根据需要发送数据.例如,将此与具有固定已知长度的数组进行对比.
The term stream is an abstraction of a construct that allows you to send or receive an unknown number of bytes. The metaphor is a stream of water. You take the data as it comes, or send it as needed. Contrast this to an array, for example, which has a fixed, known length.
使用流的示例包括读取和写入文件、通过外部连接接收或发送数据.然而,术语stream 是通用的,并没有说明具体的实现.
Examples where streams are used include reading and writing to files, receiving or sending data across an external connection. However the term stream is generic and says nothing about the specific implementation.
这篇关于什么是 C++ 中的流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:什么是 C++ 中的流?
基础教程推荐
- CString 到 char* 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
