C ++模板错误:" "未知模板名称"在Xcode中

时间:2014-08-01 21:49:04

标签: c++ class templates inheritance hierarchy

我正在使用此类模板层次结构编写代码:

template<class T>
class function{
protected:
    T *f;
    int N0, N;
public:
    T& operator[](int i) {Assert(i<N,"Out of range in function[]"); return f[i];}
    const T& operator[](int i) const {Assert(i<N,"Out of range in function[]"); return f[i];}
    const T& last() const {return f[N-1];}
    int size() const { return N;}
    int fullsize() const { return N0;}
    function& operator+=(const function& m);
    function& operator*=(const T& m);
    T* MemPt(){return f;}
    const T* MemPt() const{return f;}
    function& operator=(const T& c);
protected:
    function() : f(NULL), N0(0), N(0) {};
    explicit function(int N_) : N0(N_), N(N_) {};
    ~function(){};
    function(const function&){};
    template<class U> friend class function2D;
    template <class U> friend U scalar_product(const function<U>& f1, const function<U>& f2);
};

//******************************************************************//
// One dimensional functions derived from function<T>. It has it's  //
// own constructors and destructors.                    //
//******************************************************************//
template <class T>
class function1D : public function<T>{   //HERE IS THE ERROR 
public:
    function1D(){};
    explicit function1D(int N_);
    ~function1D();
    function1D(const function1D& m);
    void resize(int N_);
    function1D& operator=(const function1D& m);
    function1D& operator=(const T& c) {function<T>::operator=(c); return *this;}
    void Product(const function2D<T>& A, const function<T>& x, double alpha=1., double beta=0.);
};

我在“HERE IS THE ERROR”指定的行中收到此错误

错误:“未知模板名称'功能'

我完全感到困惑,因为这似乎只是一个简单的继承!

我在Xcode 5.1.1中使用这个C ++代码

0 个答案:

没有答案