Eclipse C++:class、命名空间、未找到枚举
Eclipse C++: class, namespace, enumeration not found
问候并提前致谢!
我正在使用 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
但无济于事。非常感谢任何帮助!
这部分是错误的。
int ROWS, COLS ;
int colix[COLS], rowix[ROWS] ;
您正在定义大小为 COLUMNS 和 ROWS 的数组。但这些是非常量成员变量。您需要编译时表达式。例如:
static constexpr int ROWS = 4;
static constexpr int COLS = 4;
你应该这样写函数的定义:
template <class T>
Matx<T>::~Matx(){
delete this->array ;
}// end ~matx()
问候并提前致谢!
我正在使用 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
但无济于事。非常感谢任何帮助!
这部分是错误的。
int ROWS, COLS ;
int colix[COLS], rowix[ROWS] ;
您正在定义大小为 COLUMNS 和 ROWS 的数组。但这些是非常量成员变量。您需要编译时表达式。例如:
static constexpr int ROWS = 4;
static constexpr int COLS = 4;
你应该这样写函数的定义:
template <class T>
Matx<T>::~Matx(){
delete this->array ;
}// end ~matx()