Search code examples
c++eclipse-cdt

Eclipse C++: class, namespace, enumeration not found


Greetings and thank you in advance!

I'm working in macOS X 10.12; Eclipse Neon 4.6, Compiling using macOS X GCC. I am receiving the following error:

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

The error is confusing due to the following matrix.h file:

#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()

Note there are a few more functions in the file, but the error is consistent across all of them. I have tried defining the functions with scope resolution and without, i.e. Matx::~m but to no avail. Any help is much appreciated!


Solution

  • You should write the definition of the function like this:

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