免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1233 | 回复: 2
打印 上一主题 下一主题

下列代码中“using namespace std;”为何意? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-10-16 11:51 |只看该作者 |倒序浏览
#include <iostream.h>;
#include <deque>;

using namespace std;    //这行代码,缺了又不行!

int main()
{
        deque<int>; coll;

        coll.push_front(1);
        coll.push_front(2);
        coll.push_front(10);
        coll.push_front(5);
        coll.push_front(4);
        coll.push_front(;
        coll.push_back(11);
        coll.push_back(15);

        for(int i = 0; i < coll.size(); i ++)
        {
                cout << coll << ' ';
        }
        cout << endl;
        cout << coll.back() << endl;
        return 1;
}

论坛徽章:
0
2 [报告]
发表于 2003-10-16 11:53 |只看该作者

下列代码中“using namespace std;”为何意?

既使用命名空间std.很多c++库包括stl,iostream都归入了命名空间std.如果对命名空间的概念不清楚,建议去看资料。

论坛徽章:
0
3 [报告]
发表于 2003-10-16 17:06 |只看该作者

下列代码中“using namespace std;”为何意?

如果没有那句话你的 deque,cout都成undefine了
#include <iostream.h>;
#include <deque>;

//using namespace std; //这行代码,缺了又不行!
//现在不要这行了

int main()
{
deque<int>; coll;

std::coll.push_front(1);
std::coll.push_front(2);
std::coll.push_front(10);
std::coll.push_front(5);
std::coll.push_front(4);
std::coll.push_front(;
std::coll.push_back(11);
std::coll.push_back(15);

for(int i = 0; i < coll.size(); i ++)
{
std::cout << coll << ' ';
}
std::cout << endl;
std::cout << coll.back() << endl;
return 1;
}
你在这样编译,就能过
明白了么?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP