iostream原理,vc中iostream是什么意思

1,vc中iostream是什么意思标准输入输出头文件
2,关于iostreamh文件的理解头文件不是一定就是函数的声明,只不过C++是一种结构的 , 为了便于管理,在创建类的时候把类的声明放在.h文件,类的实现放在.cpp文件 。其实你可以把.h的文件copy到.cpp文件里,程序照样没错(但要注意把cpp文件里的include(***.h)包含去掉) 。可以这样只是C++的一种管理方法 。同理也可以把CPP的文件COPY到.H文件里 。象iostream.h就是这样一个文件包含了所涉及的io的实现 。
3,C中iostreamh是什么iostream.h 是标准的输入输出流头文件 包含 cin>>要输入的东西 cout<来声明头文件 其他的输入输出方式有 getchar(要输入的字符) putchar(要输出的字符);//适合单纯字符的输入输出 scanf(要输入的东西) printf(要输出的东西);//适合有明确的格式要求的输入输出 相关的书籍建议看一下《C++编程思想 第一卷:标准C++导引》(英文名:Thinking in C++)头文件,这个库中包含C++中最基本的执行语句 。【iostream原理,vc中iostream是什么意思】
4,为什么说C中iostream和iostreamh是两个不同的概念他们俩的主要区别就是,当代码中用<iostream.h>时,输出可直接引用cout<<x; <iostream.h>继承C语言的标准库文件 , 未引入名字空间定义,所以可直接使用 , 不需要加std::,不用using namespace std;等 。而当代码中用<iostream>时,由于引入了名字空间,输出需要引用std::cout<<x;如果还是不加std::就会有错 。使用<iostream>时,引入std::有以下方法:1.using namespace std; cout<<x;2.using std::cout; cout<<x;3.直接用std::cout<<x;5,iostream 是 C 的缺陷吗为什么不是 。举几个简单例子来阐述理由 。#include using namespace std; class A { public: explicit A(int i) : data(i){} private: int data; friend ostream& operator << (ostream& out, const A& a); }; ostream& operator << (ostream& out, const A& a) { out << a.data; return out; } int main() { A a(47); cout << a << endl; return 0; } 如果不使用iostream,那么你使用printf如何自定义输出a?所以,这里体现出了iostream的扩展性 。#include #include using namespace std; void f(istream& in) { // balabala } int main() { ifstream in("a.txt"); f(in); f(cin); return 0; } 由于iostream是实际的class,其具有继承性,所以你可以如此轻易的实现多态,而stdio却是FILE* 。

    推荐阅读