简体   繁体   中英

difference between basic_iostream and iostream?

I have done my research before posting this question,and made sure there was not similar questions asked.

I am reading this article http://www.ntu.edu.sg/home/ehchua/programming/cpp/cp10_io.html on streams in C++,and in the diagram in the link I noticed in blue there is basic_iostream and underneath it in green is iostream,the same goes for basic_ifstream and ifstream and so on,

from what I read is that basic_iostream is a template class and iostream is an instantiation of basic_iostream,but what is meant by this?

iostream is not an object like cout,cin and cerr so how is it an instantiation?

In namespace std there's a typedef:

typedef basic_iostream<char, char_traits<char>> iostream;

That defines iostream as a synonym for basic_iostream<char, char_traits<char>> . When you write something like

std::iostream my_stream;

you are, in effect, writing

std::basic_iostream<char, std::char_traits<char>> my_stream.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM