First, I know that this problem has already been treated here, but I have not been able to solve it.
I have several classes, which are LitteralPart, Monome, Polynome and PolynomialFraction. They all have to be able to use each other, (i.e. Monome have to be able to owns methods which could return PolynomialFraction), but when I try to compile the program, I get around 400 like
"Polynome" does not name a type
"Monome" is not declared
"LitteralPart" is not declared in this scope
and so on.
Each of headers file are as the following :
#ifndef // Variable for the file
#define // Variable for the file
#include "includes.h" // Contains several includes like <QString> or <QVector>
#include // All others class headers
class Class
{
// Class definition
};
// Operators overloading
For example, here is the Polynome header with all errors in comment :
#ifndef POLYNOME_H
#define POLYNOME_H
#include "includes.h"
#include "monome.h"
#include "polynomialfraction.h"
#include "math.h"
class Polynome
{
public:
Polynome();
Polynome(QString polynome);
void setMonomeVector(QVector<Monome> monomeVector);
/*
"Monome" was not declared in this scope
template argument 1 is invalid
"Monome" was not declared in this scope
template argument 1 is invalid
"Monome" was not declared in this scope
template argument 1 is invalid
"Monome" was not declared in this scope
template argument 1 is invalid
"Monome" was not declared in this scope
template argument 1 is invalid
*/
QVector<Monome> getMonomeVector()const;
/*
"Monome" was not declared in this scope
template argument 1 is invalid
"Monome" was not declared in this scope
template argument 1 is invalid
"Monome" was not declared in this scope
template argument 1 is invalid
"Monome" was not declared in this scope
template argument 1 is invalid
"Monome" was not declared in this scope
template argument 1 is invalid
*/
int getConstantValue();
QStringList getLitteralParts() const;
void simplify();
void invert();
int getDegree() const;
QString toString()const;
void operator+=(Monome const& other);
/*
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
*/
void operator+=(Polynome const& other);
void operator-=(Monome const& other);
/*
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
*/
void operator-=(Polynome const& other);
void operator*=(int const& other);
/*
with "void operator*=(int const& other)";
with "void operator*=(int const& other)";
with "void operator*=(int const& other)";
with "void operator*=(int const& other)";
with "void operator*=(int const& other)";
*/
void operator*=(Monome const& other);
/*
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
*/
void operator*=(Polynome const& other);
void operator/=(int const& other);
/*
with "void operator/=(int const& other)";
with "void operator/=(int const& other)";
with "void operator/=(int const& other)";
with "void operator/=(int const& other)";
with "void operator/=(int const& other)";
*/
void operator/=(Monome const& other);
/*
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
*/
void operator/=(Polynome const& other);
void operator=(QString const& value);
void operator=(const char* value);
private:
QVector<Monome> monomeVector;
/*
"Monome" was not declared in this scope
template argument 1 is invalid
"Monome" was not declared in this scope
template argument 1 is invalid
"Monome" was not declared in this scope
template argument 1 is invalid
"Monome" was not declared in this scope
template argument 1 is invalid
"Monome" was not declared in this scope
template argument 1 is invalid
*/
};
Polynome operator+(Polynome const& a, Monome const& b);
/*
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
*/
Polynome operator+(Polynome const& a, Polynome const& b);
Polynome operator-(Polynome const& a, Monome const& b);
/*
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
*/
Polynome operator-(Polynome const& a, Polynome const& b);
Polynome operator*(Polynome const& a, int const& b);
Polynome operator*(int const& b, Polynome const& a);
Polynome operator*(Polynome const& a, int const& b);
Polynome operator*(Polynome const& a, Monome const& b);
/*
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
*/
Polynome operator*(Polynome const& a, Polynome const& b);
Polynome operator/(Polynome const& a, int const& b);
Polynome operator/(int const& b, Polynome const& a);
Polynome operator/(Polynome const& a, Monome const& b);
/*
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
*/
Polynome operator/(Monome const& b, Polynome const& a);
/*
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
"Monome" has not been declared
*/
Polynome operator/(Polynome const& a, Polynome const& b);
#endif // POLYNOME_H
There are the same problems in all others files.
All those files, except includes.h have been placed in a subdirectory of the project, but if I use #include "polynome.h"
, #include "variables/polynome.h"
or even their absolute path, that changes nothing.