gpt4 book ai didi

c++ - Eclipse C++ : class, 命名空间,未找到枚举

转载 作者:行者123 更新时间:2023-11-30 05:09:44 25 4
gpt4 key购买 nike

提前问候并感谢您!

我在 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++ : class, 命名空间,未找到枚举,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46012632/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com