Salut!![]()
En tentant de compiler ce code:
les erreurs pleuvent:
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114 #ifndef ELECTRONIC #define ELECTRONIC #include <vector> #include <string> #ifndef BIT typedef char BIT; #else #error BIT is already defined #endif class Component; class ComponentPort; class BooleanPolynom; class BinaryOperator; class Bit; class Component{ private: unsigned fanIn; unsigned fanOut; std::string name; std::vector<ComponentPort*> inBuffer; std::vector<ComponentPort*> outBuffer; BooleanPolynom function; public: /*Default constructor*/ Component():fanIn(0),fanOut(0){}; /*Binary constructor*/ Component(unsigned _fanIn,unsigned _fanOut):fanIn(_fanIn),fanOut(_fanOut){} std::string getName(void); unsigned getFanIn(void); unsigned getFanOut(void); }; class ComponentPort{ private: Component* currentComponent; Component* connectedComponent; Bit value; unsigned index; public: Bit getValue(void); unsigned getIndex(void); Component* getCurrentComponent(void); Component* getConnectedComponent(void); }; class BooleanPolynom{ private: bool isBit; BinaryOperator binaryOperator; BooleanPolynom* leftBooleanPolynom; BooleanPolynom* rightBooleanPolynom; public: Bit evaluate(void); }; Bit BooleanPolynom::evaluate(void){ if(isBit){ return (static_cast<Bit> (this))->value; } Bit firstOperand=leftBooleanPolynom->evaluate(); Bit secondOperand=rightBooleanPolynom->evaluate(); return binaryOperator(firstOperand,secondOperand); } class Bit : public BooleanPolynom{ private: BIT value; public: Bit(BIT _value):value(_value){} BIT getValue(void); }; BIT Bit::getValue(void){ return value; } class BinaryOperator{ public: virtual Bit operator()(Bit b0,Bit b1)=0; }; class AND : public BinaryOperator{ Bit operator()(Bit b0,Bit b1){ Bit result((b0.getValue())&(b1.getValue())); return result; } }; #endifBeaucoup semble étranges:
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 32 field `function' has incomplete type 50 field `value' has incomplete type 65 field `binaryOperator' has incomplete type In member function `Bit BooleanPolynom::evaluate()': 74 return type `struct Bit' is incomplete 77 invalid use of undefined type `struct Bit' 18 forward declaration of `struct Bit' 80 variable `Bit firstOperand' has initializer but incomplete type 80 invalid use of undefined type `struct Bit' 18 forward declaration of `struct Bit' 81 variable `Bit secondOperand' has initializer but incomplete type 81 invalid use of undefined type `struct Bit' 18 forward declaration of `struct Bit' 83 `binaryOperator' undeclared (first use this function)
-les "incomplete type" alors que les classes sont définies.
-les "forward declaration" alors que ce ne sont que des déclarations.
Merci de votre aide.![]()
Partager