#include 问题

来源:百度知道 编辑:UC知道 时间:2024/05/05 07:20:15
为什么#include <iostream>这个样子可以找到文件,而#include <iostream.h>就会出现这个错误:\My_name.cpp(4) : fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory
为什么#include <iostream>没有.h
而#include "iostream.h"有.h,不是同一个文件名么?

这两个是完全不同的文件;在我的G++实现中是这样的:

iostream.h:(略去版权声明注释)
#ifndef _BACKWARD_IOSTREAM_H
#define _BACKWARD_IOSTREAM_H 1

#include "backward_warning.h"
#include <iostream>

using std::iostream;
using std::ostream;
using std::istream;
using std::ios;
using std::streambuf;

using std::cout;
using std::cin;
using std::cerr;
using std::clog;
#ifdef _GLIBCXX_USE_WCHAR_T
using std::wcout;
using std::wcin;
using std::wcerr;
using std::wclog;
#endif

using std::ws;
using std::endl;
using std::ends;
using std::flush;

#endif

而iostream是这样的:
#ifndef _GLIBCXX_IOSTREAM
#define _GLIBCXX_IOSTREAM 1

#pragma GCC system_header

#include <bits/c++config.h>
#include <ostream>
#include <istream>

namespace std
{
/**
* @name Standard Stream Object