我有一个名为 Nuage 的类(它是点的集合),我将在其中使用类 Vector 的函数来操作该类。nuage.cpp 文件是:
#include <iostream>
#include "nuage.hpp"
template <typename T>
Nuage<T>::Nuage(){}
template <typename T>
void Nuage<T>::ajouter(const T& p) {
v.push_back(p);
}
template <typename T>
unsigned int Nuage<T>::size() const {
return v.size();
}
template <typename T>
const_iterator Nuage<T>::begin() const{
return v.begin();
template <typename T>
Nuage<T>::~Nuage(){}
nuage.hpp 是:
#ifndef NUAGE_HPP
#define NUAGE_HPP
#include <cstdlib>
#include <sstream>
#include <vector>
template <typename T>
class Nuage {
private:
std::vector<T> v;
public:
using const_iterator = typename std::vector<T>::const_iterator;
Nuage();
void ajouter(const T&);
unsigned int size() const;
const_iterator begin() const;
~Nuage();
};
#endif
我有一个错误说:
error: ‘const_iterator’ does not name a type; did you mean ‘constexpr’?
错误在这一行:const_iterator Nuage<T>::begin() const{
有人可以帮我找到吗?谢谢