返回   cpper编程论坛 > C/CPP/TMP/GP
注册账号 论坛帮助 会员列表 日历事件 搜索 今日新帖 标记版面已读

回复
 
LinkBack 主题工具 显示模式
  #1 (permalink)  
旧 2008-10-11
初级会员
 
注册日期: 2008-04-18
帖子: 6
BlueSky-Thinker 正向着好的方向发展
默认 g++ 中使用异常

源文件:
#include<iostream>
#include<exception>
using namespace std;

int main()
{
cout<<"for test";
throw out_of_range("out of range");
}
编译错误:
test.cpp:8: 错误: ‘out_of_range’在此作用域中尚未声明。这是我在一本数据结构书上看到的用法,在我这怎么不行了呢?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #2 (permalink)  
旧 2008-10-11
polyrandom 的头像
超级版主
 
注册日期: 2002-09-03
帖子: 3,138
文章: 20
polyrandom 正向着好的方向发展
默认 回复: g++ 中使用异常

你有G++或者STL的文档吗?如果你没有,我建议你立即去找一份。
至少,在我这里看来,你的头文件包含错了。你应该检查一下out_of_range是在哪个头文件里。
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #3 (permalink)  
旧 2008-10-11
初级会员
 
注册日期: 2008-04-18
帖子: 6
BlueSky-Thinker 正向着好的方向发展
默认 回复: g++ 中使用异常

哦,谢谢。我去找看看。但是,异常应该在exception中啊。
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #4 (permalink)  
旧 2008-10-21
bankrock 的头像
高级会员
 
注册日期: 2003-12-11
帖子: 847
文章: 7
bankrock 正向着好的方向发展
默认 回复: g++ 中使用异常

引用自C++ Standard Library:
引用:
The base class exception and class bad_exception are defined in <exception>. Class bad_alloc is defined in <new>. Classes bad_cast and bad_typeid are defined in <typeinfo>. Class ios_base::failure is defined in <ios>. All other classes are defined in <stdexcept>.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
回复

书签

标签
c++ 异常

主题工具
显示模式

发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码
Trackbacks are 启用
Pingbacks are 启用
Refbacks are 启用



所有时间均为格林尼治时间 +9。现在的时间是 09:46 AM


Powered by vBulletin® 版本 3.7.0
版权所有 ©2000 - 2009,Jelsoft Enterprises Ltd.
(C) Copy Right All Right Reserved 2001 - 2007

Search Engine Friendly URLs by vBSEO 3.1.0