I have 2 classes in 2 different files:
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
On the constructor lines I get the errors:
error C4430: missing type specifier - int assumed.
error C2143: syntax error : missing ',' before '&'
But when i add the classes declarations
class SparseMatrix;
in the RegMatrix.h file and
class RegMatrix;
in the SparseMatrix.h file it works fine. My question is why is it needed if i have the includes? 10x.