我有兩個班在2個不同的文件:「缺少類型說明」 錯誤
RegMatrix.h:
#ifndef _RM_H
#define _RM_H
#include "SparseMatrix.h"
...
class RegMatrix{
...
RegMatrix(const SparseMatrix &s){...} //ctor
...
};
#endif
SparseMatrix.h:
#ifndef _SM_H
#define _SM_H
#include "RegMatrix.h"
...
class SparseMatrix{
...
SparseMatrix(const RegMatrix &r){...} //ctor
...
};
#endif
在構造函數行我得到的錯誤:
錯誤C4430:缺少類型說明符 - int假定。
錯誤C2143:語法錯誤:之前 '&' 失蹤 ''
但是,當我添加了類聲明
class SparseMatrix;
在RegMatrix.h文件和
class RegMatrix;
在SparseMatrix.h文件中它工作正常。 我的問題是爲什麼它需要,如果我有包括? 10x。
標識符_RM_H和_SM_H是[保留](http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-ac-identifier ),請勿使用它們。 – GManNickG 2010-09-27 18:15:07