J'ai un pb sur le code suivant:
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 typedef struct _SonContainer { ThreatNode *a_node; _SonContainer *next; } SonContainer; class ThreatNode { private: SonContainer *son; OPERATOR op; char name[NAME_SIZE]; char comment[COMMENT_SIZE]; int probability[PROBABILITY_SIZE]; bool is_root; bool is_treated; public: ThreatNode(OPERATOR, bool is_root = false); OPERATOR getOperator(); void setOperator(OPERATOR); void printProbability(); void setProbability(int[PROBABILITY_SIZE]); int getProbability(int); bool isRoot(); void setIsRoot(); bool isTreated(); void setIsTreated(); char* getName(); void setName(char*); char* getComment(); void setComment(char*); SonContainer* getSon(); void addSon(ThreatNode*); int evaluate(int); // evaluate the probability void printNode(); };
dans mon main je fais
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 int ThreatNode::evaluate(int k) { cout << "je print la prob de "<<this->getName()<<"\n"; this->printProbability(); SonContainer *a_son_container, *a_brother_container; ThreatNode *a_son, *a_brother; int prob, final_prob; if (this->isTreated()) return this->probability[k];; //a_son = this->son; a_son_container = this->son; if (a_son_container == NULL) { if (this->op != LEAF) printf("WARNING: the node %s should be LEAF\n", this->getName()); return this->probability[k]; } a_son = a_son_container->a_node; final_prob = a_son->evaluate(k); a_son->setIsTreated(); a_brother_container = a_son_container->next; while (a_brother_container != NULL) { a_brother = a_brother_container->a_node; prob = a_brother->evaluate(k); a_brother->setIsTreated(); if (this->op == AND) final_prob = min_prob(final_prob, prob); else final_prob = max_prob(final_prob, prob); a_brother_container = a_brother_container->next; } this->probability[k] = final_prob; return final_prob; }
ThreatNode *root;
...
root->evaluate(0);
root->evaluate(1);
En faite evaluate(0) doit me renvoyer une proba pour une catégorie de personne et evaluate(1) pour une autre catégorie.
Et pour ce faire chaque objet possède en donnée membre un tableau de proba, chaque case correspond a 1 type de personne.
Ce que je pensais c ke evaluate 0 va travailler sur tout mes objets, mais précisément sur la donnée membre probability[0],... et de même pour evaluate 1 qui devrait travailler sur probability[1] de tout mes objets.
mais je contaste que root->evaluate(0); puis root->evaluate(1)
ne fais pas ce je j'escompte: on dirait que c 2 root différents alors que c le même., il fait le traitement sur evaluate(0); et le fait sur evaluate(1) sans tenir compte que evaluate(0) a modifier la donnée membre probability[0].
Voila.
J'espère avoir été claire.
Un petit coup de main serait le bien venu
Partager