Salut à tous
Bon je pense que le code vaut mieux qu'un gros discours donc le voici:
AbstractShip.h
FactoryForShip.h
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 #ifndef __FIGHTER_ #define __FIGHTER_ 1 #include "Strike.h" class AbstractShip { private: int HitPoints; void* strikeFactory; protected: AbstractShip(); ~AbstractShip(); Strike *nextHit(); public: void setHitPoints(int); int getHitPoints(); virtual Strike fight() = 0; virtual bool dodge(Strike) = 0; }; #endif
Tief.h
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 #ifndef __FACTORYFORSHIP_ #define __FACTORYFORSHIP_ 1 #include<iostream> #include <string> #include "AbstractShip.h" #include "fct_strike.h" using namespace std; class FactoryForShip:public AbstractShip { private: string Name; string Command; int nbAllowedAttacks; int *AllowedAttacks; int *MBonus; int nbDefaultAttacks; int *DefaultAttacks; int Shield; int Handling; int StrikeCost; bool Hidden; bool LastDefence; protected: bool IsAllowed(Strike); public: FactoryForShip(); FactoryForShip(string _Name, string _Command, int _nbAllowedAttacks, int* _AllowedAttacks, int* _MBonus, int _nbDefaultAttacks,int *_DefaultAttacks, int _LifePoints, int _Shield, int _Handling, int _StrikeCost, bool _Hidden); ~FactoryForShip(); string getName(); void setName(string); string getCommand(); void setCommand(string); int getnbAllowedAttacks(); void setnbAllowedAttacks(int); int* getMBonus(); void setMBonus(int* _MBonus); int* getAllowedAttacks(); void setAllowedAttacks(int*); int getnbDefaultAttacks(); void setnbDefaultAttacks(int); int* getDefaultAttacks(); void setDefaultAttacks(int*); int getShield(); void setShield(int); int getHandling(); void setHandling(int); int getStrikeCost(); void setStrikeCost(int); bool getHidden(); void setHidden(bool); bool getLastDefence(); void setLastDefence(bool); virtual Strike GetDefauldStrike() = 0; Strike fight(); bool dodge(Strike&); }; #endif
et quand je fait
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 #ifndef _TIEF_H #define _TIEF_H 1 #include <iostream> #include <string> #include "FactoryForShip.h" using namespace std; class TieF:public FactoryForShip { private: int LastDefault; public: TieF(); ~TieF(); int getLastDefault(); void setLastDefault(int); Strike GetDefauldStrike(); }; #endif
le compilateur me retourne:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2TieF *v; v=new TieF;
error C2259: 'TieF' : cannot instantiate abstract class due to following members:
g:\codecpp\tp5\tief.h(11) : see declaration of 'TieF'
Il y a un post similaire sur le forum ou la personne avait oublié de declarer une methode virtuelle mais moi j'ai verifié et j'ai pas l'impression que ca soit le cas.
Vous voyez ce qui lui plait pas? J'en ai marre qu'il m'injurie comme ca lol
Merci
Partager