小编Yur*_* G.的帖子

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();
...
Run Code Online (Sandbox Code Playgroud)

但编译器给我下一个错误:

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
Run Code Online (Sandbox Code Playgroud)

c++ templates iterator stl typename

1
推荐指数
1
解决办法
2749
查看次数

标签 统计

c++ ×1

iterator ×1

stl ×1

templates ×1

typename ×1