问候和预先感谢您!

我正在macOS X 10.12中工作; Eclipse Neon 4.6,使用macOS X GCC进行编译。我收到以下错误:

../matrix.h:82:1: error: 'Matx' is not a class, namespace, or enumeration
`Matx::~matx(){`
`^`
`../matrix.h:27:7: note: 'Matx' declared here`

由于以下matrix.h文件,该错误令人困惑:
#ifndef MATRIX_H_
#define MATRIX_H_
#include <iostream>
template <class T>
class Matx {
    int ROWS, COLS ;
    int colix[COLS], rowix[ROWS] ;
    T ** array ;

    Matx(int, int) ;
    ~Matx() ;
    void rowSwap() ;
    void size( void ) ;
    void swapRows(int i1, int i2) { std::swap(this->array[i1], this->array[i2]); }
    void printMat( void ) ;


};// end class matrix

template <class T>
Matx::~Matx(){
    delete this->array ;
}// end ~matx()

请注意,文件中还有其他几个函数,但是所有这些函数中的错误都是一致的。我曾尝试使用范围解析和不使用Matx::~m来定义函数,但无济于事。任何帮助深表感谢!

最佳答案

您应该这样编写函数的定义:

template <class T>
Matx<T>::~Matx(){
    delete this->array ;
}// end ~matx()

关于c++ - Eclipse C++:未找到类, namespace ,枚举,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46012632/

10-11 23:03
查看更多