LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 847|回复: 6

linux下如何用STL编程?

[复制链接]
发表于 2003-5-6 11:33:11 | 显示全部楼层 |阅读模式
在GCC中不是已经整合了SGI STL了吗?我用GCC编译如下程序,该程序是孟岩
“在 Borland C++ 及 Visual C++ 環境中使用 STLport”的例子。
//issgistl.cpp
#include <iostream>
#include <rope>

using namespace std;

int main()
{
    // crope就是容納char?型字符的rope容器
    crope bigstr1("It took me about one hour ");
    crope bigstr2("to plug the STLport into Borland C++!");
    crope story = bigstr1 + bigstr2;
    cout << story << endl;
    return 0;
}
错误提示找不到<rope>.
用GCC -I把rope的路径加上后,rope中嵌入的许多头文件又找不到。请高手指点一下。
 楼主| 发表于 2003-5-6 11:34:20 | 显示全部楼层

补充上贴

我的系统是Red hat 9.0
发表于 2003-5-6 12:22:58 | 显示全部楼层
你到你的/usr/include里面看看有没有rope这个头文件?
我的系统是RH73只在g++-3这个目录里面找到了
 楼主| 发表于 2003-5-6 12:38:08 | 显示全部楼层
在RH9下也是在g++-3这个目录下。
发表于 2003-5-6 17:42:44 | 显示全部楼层
g++ -I/usr/include/c++-3 ... 试试
 楼主| 发表于 2003-5-7 10:31:53 | 显示全部楼层

在CSDN中有位高人的指点下解决。

#include <iostream>
#include <ext/rope>

using namespace std;
using namespace __gnu_cxx;

int main()
{
// crope就是容?{char?型字符的rope容器
crope bigstr1("It took me about one hour ");
crope bigstr2("to plug the STLport into Borland C++!");
crope story = bigstr1 + bigstr2;
cout << story << endl;
return 0;
}
发表于 2003-5-7 19:15:39 | 显示全部楼层
我看了一下<ext/rope>里面有#include <ext/stl_rope.h>,再看stl_rope.h果然有namespace __gnu_cxx,呵呵,高人说的没错。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表