dequeのサンプルプログラムでコンパイルエラー – プログラミング – Home

dequeのサンプルプログラムでコンパ...
 
通知
すべてクリア

dequeのサンプルプログラムでコンパイルエラー


きっちゃ
 きっちゃ
(@きっちゃ)
ゲスト
結合: 22年前
投稿: 5
Topic starter  

STL関連の書籍に載っていたコードをそのまま記述しましたが、コンパイルでエラーとなりま
す。どうしてよいのかわかりません。どなたかご教授いただけませんか?
プログラムは以下のとおりです。環境はwin2000 vc6++ です。
#include<iostream>
#include<cassert>
#include<deque>
#include<algorithm>
using namespace std;

template <typename Container>

Container make(const char s[])
{
return Container(&s[0], &s[strlen(s)]);
}

int main()
{
cout << "
<< " << endl;
deque<char> deque1 =make< deque<char> >(C++ is a better C);

deque<char>::iterator
where = find(deque1.begin(), deque1.end(), 'e');
assert(*where == 'e' && *(where + 1) == 't');
cout << --- Ok. << endl;
return 0;
}


引用解決済
トピックタグ
επιστημη
 επιστημη
(@επιστημη)
ゲスト
結合: 22年前
投稿: 1301
 

#include<iostream>
#include<cassert>
#include<deque>
#include<algorithm>
#include <iterator>
using namespace std;

template <typename Container>
Container make(const char s[])
{
Container result;
copy(s, s+strlen(s), back_inserter(result));
return result;
}

...以下同文


返信引用
きっちゃ
 きっちゃ
(@きっちゃ)
ゲスト
結合: 22年前
投稿: 5
Topic starter  

ありがとうございました。
これから、さらに理解できるように努力したいと思います。


返信引用

返信する

投稿者名

投稿者メールアドレス

タイトル *

プレビュー 0リビジョン 保存しました
共有:
タイトルとURLをコピーしました