私は単純な問題で助けを必要とC++テンプレートとSTLのベクトルの問題
イムクラス
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template<class T> class merge_sort
{
protected:
vector<T> merge(const vector<T> &a, const vector<T> &b)
{
vector<T> v;
typename vector<T>::iterator A;
A= a.begin();
typename vector<T>::iterator B;
B= b.begin();
...
を作成しようとしているが、コンパイラは私に次のエラーを与える:べき
no match for ‘operator=’ in ‘A = ((const std::vector<int, std::allocator<int> >*)a)->std::vector<_Tp, _Alloc>::begin [with _Tp = int, _Alloc = std::allocator<int>]()’ merge.cpp /merge_sort line 23 C/C++ Problem
なぜ "typename"をベクトル :: iterator A; 'の前に置いていますか? –
@Kiril: 'ベクトル :: iterator'は従属名なので? –
そして次の行で一度だけ使用するタイプ名 'A'を持つことで何が得られますか?また、これはテンプレートクラスであり、ヘッダーに置かれるので、ヘッダーファイルには 'namespace'を使用しない宣言はこれまでにはありません。 – Mephane