Bonjour à tous,
Je reste depuis tout à l'heure sur une erreur semble t-il de syntaxe :s
Je vous fais voir mon code :
classe Entier
et classe Fraction :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 // Entier.h #ifndef E_H #define E_H #include "Fraction.h" #include <iostream> using namespace std; class Entier { int nombre; public : //constructeurs Entier(const int=0); //Opérateuns d'action Entier& operator*(const Fraction&); Entier& operator*(const Entier&); Entier& operator+(const Fraction&); Entier& operator+(const Entier&); Entier& operator-(const Fraction&); Entier& operator-(const Entier&); Entier& operator/(const Fraction&); Entier& operator/(const Entier&); Entier& operator=(const Fraction&); Entier& operator=(const Entier&); //Opérateurs de test bool operator>(const Fraction&); bool operator>(const Entier&); bool operator>=(const Fraction&); bool operator>=(const Entier&); bool operator<(const Fraction&); bool operator<(const Entier&); bool operator<=(const Fraction&); bool operator<=(const Entier&); bool operator==(const Fraction&); bool operator==(const Entier&); bool operator!=(const Fraction&); bool operator!=(const Entier&); //Fonctions amies friend ostream& operator<<(ostream&, Entier&); //opérateurs de flux (ex : cout) friend istream& operator>>(istream& , Entier&); //opérateurs de flux (ex : cin) }; #endifD'après ce que j'ai vu cela vient des appels à Entier dans la classe Fraction et vice versa, je ne comprends pas l'erreur étant donné que j'ai bien mis mes includes entre les ifndef.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 #ifndef F_H #define F_H #include "Entier.h" #include <iostream> using namespace std; //--------------------------------------------------------------------------- class Fraction { int Num; int Denom; public : //constructeurs Fraction(const int, const int); Fraction(const int); Fraction(); //Opérateuns d'action Fraction& operator*(const Fraction&); Fraction& operator*(const Entier&); Fraction& operator+(const Fraction&); Fraction& operator+(const Entier&); Fraction& operator-(const Fraction&); Fraction& operator-(const Entier&); Fraction& operator/(const Fraction&); Fraction& operator/(const Entier&); Fraction& operator=(const Fraction&); Fraction& operator=(const Entier&); //Opérateurs de test bool operator>(const Fraction&); bool operator>(const Entier&); bool operator>=(const Fraction&); bool operator>=(const Entier&); bool operator<(const Fraction&); bool operator<(const Entier&); bool operator<=(const Fraction&); bool operator<=(const Entier&); bool operator==(const Fraction&); bool operator==(const Entier&); bool operator!=(const Fraction&); bool operator!=(const Entier&); //Fonctions amies friend ostream& operator<<(ostream&, Fraction&); //opérateurs de flux (ex : cout) friend istream& operator>>(istream& , Fraction&); //opérateurs de flux (ex : cin) friend int Pgcd(const int&,const int&); // trouve le plus grand diviseur commun entre i1 et i2 //Fonctions diverses Fraction& Simp(); //Simplifie une fraction Fraction& Puis(const int&); //comme un opérateur puissance Fraction& Inv(); //Inverse la fraction int Signe(); // 1 = positif ou nul -1 = négatif void MemeDenom(Fraction&,Fraction&); // met les deux fractions au meme dénominateur int ValAprox(); }; #endif
L'erreur est exactement la suivante :
Elle se répète 22 fois à chaque appel à Fraction dans Entier et vice versa
Code : Sélectionner tout - Visualiser dans une fenêtre à part /home/guillaume/Documents/M1/projetcpp/ProjetC++/Fraction.h|19|error: ISO C++ forbids declaration of Entier with no type|
Merci d'avance pour votre aide
Partager