error C2501: 'Matrix::Complex' : missing storage-class or type specifiers 是什么原因呢?
:errorC2143:syntaxerror:missing';'before'&':errorC2501:'Matrix::Complex':missingstora...
: error C2143: syntax error : missing ';' before '&'
: error C2501: 'Matrix::Complex' : missing storage-class or type specifiers
error C2501: 'Matrix::operator`()'' : missing storage-class or type specifiers
程序如下:
//构造矩阵类MATRIX_H
#ifndef MATRIX_H
#define MATRIX_H
#include <Complex>
#include <iostream>
using namespace std;
class Matrix
{
friend ostream & operator<<(ostream &,const Matrix &);
friend istream & operator>>(istream &,Matrix &);//输入矩阵元素时,列之间请以“,”隔开,行之间请以“;”隔开
friend Matrix diag(Matrix &);//提取方阵对角元素
friend Matrix con(Matrix &);//求共轭矩阵
public:
Matrix(int r=0,int c=0);
Matrix(const Matrix &M);
~Matrix();
int getRow() const;
int getCol() const;
int getsize() const;
Complex& operator()(int i,int j);//引用
const Matrix &operator=(const Matrix &);//赋值
Matrix operator==(const Matrix &) const;//判断相等,输出相同大小的矩阵 比较的两个矩阵应该行列相等
Matrix operator!=(const Matrix &) const;//判断不等,输出相同大小的矩阵 比较的两个矩阵应该行列相等
Matrix operator~();//矩阵转置
Matrix operator+(Matrix &);//矩阵元素相加
Matrix operator-(Matrix &);//矩阵元素相减
Matrix operator*(Matrix &);//矩阵元素相乘
Matrix operator/(Matrix &);//矩阵元素相除
Matrix operator&(Matrix &);//矩阵乘法
static int getMatrixCount();
private:
Complex *ptr;
int Row;
int Col;
int size;
static int MatrixCount;
};
#endif
... 展开
: error C2501: 'Matrix::Complex' : missing storage-class or type specifiers
error C2501: 'Matrix::operator`()'' : missing storage-class or type specifiers
程序如下:
//构造矩阵类MATRIX_H
#ifndef MATRIX_H
#define MATRIX_H
#include <Complex>
#include <iostream>
using namespace std;
class Matrix
{
friend ostream & operator<<(ostream &,const Matrix &);
friend istream & operator>>(istream &,Matrix &);//输入矩阵元素时,列之间请以“,”隔开,行之间请以“;”隔开
friend Matrix diag(Matrix &);//提取方阵对角元素
friend Matrix con(Matrix &);//求共轭矩阵
public:
Matrix(int r=0,int c=0);
Matrix(const Matrix &M);
~Matrix();
int getRow() const;
int getCol() const;
int getsize() const;
Complex& operator()(int i,int j);//引用
const Matrix &operator=(const Matrix &);//赋值
Matrix operator==(const Matrix &) const;//判断相等,输出相同大小的矩阵 比较的两个矩阵应该行列相等
Matrix operator!=(const Matrix &) const;//判断不等,输出相同大小的矩阵 比较的两个矩阵应该行列相等
Matrix operator~();//矩阵转置
Matrix operator+(Matrix &);//矩阵元素相加
Matrix operator-(Matrix &);//矩阵元素相减
Matrix operator*(Matrix &);//矩阵元素相乘
Matrix operator/(Matrix &);//矩阵元素相除
Matrix operator&(Matrix &);//矩阵乘法
static int getMatrixCount();
private:
Complex *ptr;
int Row;
int Col;
int size;
static int MatrixCount;
};
#endif
... 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询