ios basic_ios和ios_base 的区别

本文深入探讨了C++中ios、ios_base和basic_ios三者之间的关系,揭示了它们在标准输入输出流中的作用及继承关系,对于理解C++ IO流操作具有重要意义。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

来源:

原文翻译自:StackOverflow原文地址

前言:

关于ios,作为C++的程序员肯定不陌生,最基础的,我们在设置小数位精度的时候,要用ios::fixed。作为ACM选手,最常用的ios::sync_with_stdio(false)
笔者今天在codeforces上看别人代码时,看到别人用了ios_base::sync_with_stdio(false),遂翻阅资料,在StackOverflow看到了ios basic_basic和ios_base三者的关系,记录如下:

原文:

1.The constants are actually defined in std::ios_base but std::ios (well, actually std::basic_ios<cT, Traits>)
is derived from std::ios_base. Thus, all members definedin std::ios_base can be accessed using std::ios.

2.The class std::ios_base contains all members which entirely independent of the stream's template parameter.
std::basic_ios<cT, Traits> derives from std::ios_base and output streams.

翻译:

事实上ios是父类,ios_baseios的子类,而basic_iosios是同样的。
所以ios可以访问到ios_base的所有成员

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值