< iostream>

vchalf_moon 2008-03-31 12:46:46
#include <string>
#include <iostream>//这里使用#include <iostream.h>,在main中cout就报错。
using namespace std;


void main()
{
string str("hello");
cout<<str<<endl;
cin.get();

}
VC6中 没搞明白为什么
...全文
130 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
paidfighting 2008-03-31
  • 打赏
  • 举报
回复
这就是iostream.h


// Copyright (C) 1997-1999, 2000 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.

// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.

#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

// Local Variables:
// mode:C++
// End:
  • 打赏
  • 举报
回复
记住不要使用#include <iostream.h>
paidfighting 2008-03-31
  • 打赏
  • 举报
回复
因为vc6没有iostream.h...
lxconan 2008-03-31
  • 打赏
  • 举报
回复
C++的头文件有一下几种:
(1)老版本C++头文件,就是类似<iostream.h>的头文件。不支持名字空间。完全非标准。不要用
(2)新型C++头文件(大多是C头文件在C++的移植),类似<cstdlib>的头文件。不支持名字空间。符合标准
(3)标准C++头文件如<iostream>。支持名字空间。符合标准

另,Visual C++ 6.0 是典型的很不标准的编译器,如并不是由于维护原因,考虑一下使用其他编译器吧例如 Visual C++ .NET 2003 以及之后的编译器。
xiaoxin_ye 2008-03-31
  • 打赏
  • 举报
回复
include <iostream>
这里的iostream是C++库
houdongfeng 2008-03-31
  • 打赏
  • 举报
回复
include <iostream>
这里的iostream是C++库
include <iostream.h>
这里的iostream.h是C库
wpflyshinerocks 2008-03-31
  • 打赏
  • 举报
回复
iostream.h是过失的一个头文件。 最好使用iostream
很多编译器已经没有包含前者,或者即使包含了也会提示你它过期了给你一个warning。
所以你以前用的编译器只是刚好带了前者而已。
supercow 2008-03-31
  • 打赏
  • 举报
回复
<iostream.h> 在高版本的VC已经没有了.
晨星 2008-03-31
  • 打赏
  • 举报
回复
iostream.h是C++98标准(1998年)发布之前的一个头文件,新标准中已经没有了,还有不要研究了。
最大的一个区别是,iostream中的东西都声明在std命令空间中,而旧的iostream.h没有。
fallenbluefire 2008-03-31
  • 打赏
  • 举报
回复
#include <string>
#include <iostream.h>
using namespace std;


void main()
{
std::string str("hello");
cout<<str.c_str()<<endl;
cin.get();
}

include <iostream>
这里的iostream是C++库
include <iostream.h>
这里的iostream.h是C库
fallenbluefire 2008-03-31
  • 打赏
  • 举报
回复
#include <string>
#include <iostream.h>
using namespace std;


void main()
{
std::string str("hello");
cout<<str.c_str()<<endl;
cin.get();
}

include <iostream>
这里的iostream是C++库
include <iostream.h>
这里的iostream.h是C库

64,646

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧