C++ C++;模板错误:"&引用;未知模板名称“;在Xcode中
我正在编写具有此类模板层次结构的代码:C++ C++;模板错误:"&引用;未知模板名称“;在Xcode中,c++,class,templates,inheritance,hierarchy,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,"
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.);
};
模板
类函数{
受保护的:
T*f;
int N0,N;
公众:
T&operator[](int i){Assert(iIsfunction
对function1D
直接可见,还是它填充在未包含的其他名称空间或头文件中?将其粘贴到简单的Xcode 5.1.1项目源代码中的唯一错误。cpp文件是关于const function2D&a
表示未定义的模板名称(这是正确的,因为您没有向我们提供该模板)。您是说在任何地方使用命名空间std;
吗?在这种情况下,function
将与std::function
冲突。那么,这些声明是在同一个文件中吗?其中一个与另一个不同。。。