什么是cin的数据类型
What is datatype of cin
我想知道cin到底是什么。我的意思是函数或类。
我确信它不是一个函数,因为我们使用 cin 的方式与调用的函数非常不同。
这留下了类或对象或其他选项。
到底是什么?
C++ 标准§27.4.1 [iostream.objects.overview]
#include <ios> #include <streambuf> #include <istream> #include <ostream> namespace std { extern istream cin; extern ostream cout; extern ostream cerr; extern ostream clog; extern wistream wcin; extern wostream wcout; extern wostream wcerr; extern wostream wclog; }
p1 标头声明将对象与 中声明的函数提供的标准 C 流 (27.9.2(,并包括使用这些标头所需的所有标头 对象。
你也可以看看gcc在github上的实现:
namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION // Standard stream objects. // NB: Iff <iostream> is included, these definitions become wonky. typedef char fake_istream[sizeof(istream)] __attribute__ ((aligned(__alignof__(istream)))); typedef char fake_ostream[sizeof(ostream)] __attribute__ ((aligned(__alignof__(ostream)))); fake_istream cin; fake_ostream cout; fake_ostream cerr; fake_ostream clog; #ifdef _GLIBCXX_USE_WCHAR_T typedef char fake_wistream[sizeof(wistream)] __attribute__ ((aligned(__alignof__(wistream)))); typedef char fake_wostream[sizeof(wostream)] __attribute__ ((aligned(__alignof__(wostream)))); fake_wistream wcin; fake_wostream wcout; fake_wostream wcerr; fake_wostream wclog; #endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace
cin
是 istream
类的对象
相关文章:
- 防止主数据类型C++的隐式转换
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 在C++中打印指向不同基元数据类型的指针的内存地址
- C++浮点数据类型和字符串数据类型无法子到模板函数中
- 如何计算数据类型的范围,例如int
- C++中数据类型修饰符的顺序
- C++LinkedList问题.数据类型之间存在冲突?没有匹配的构造函数
- 特定数据类型的模板类
- 具有多个模板的模板函数,用于特定数据类型(如字符串)?
- 有没有办法提示用户使用哪种数据类型作为模板 c++
- int数据类型的指针指向的是什么,如果是一个类的私有数据成员,我们创建了该类的两个对象?
- 时间复杂度 当具有复合数据类型(如元组或对)时?
- 如何获取C++字符数据类型的地址
- 将复杂的非基元C++数据类型转换为 Erlang/Elixir 格式,以使用 NIF 导出方法
- 如果用户不小心给出了不正确的数据类型,cin 如何工作?
- 使用 CIN 和 COUT 在 C++ 中声明基本数据类型
- C++:获取用户通过cin输入的数据类型
- 什么是cin的数据类型
- cin和cout如何支持不同的数据类型
- 如何使用CIN在一行中捕获两种不同的数据类型