Bonjour,

Je n'arrive pas à désallouer mes pointeurs.
Voici ma classe :

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
115
116
117
118
119
120
121
#ifndef GRAPHNODE_H
#define GRAPHNODE_H
 
#include <iostream>
#include <vector>
 
template<typename T>
class GraphNode
{
private:
	T _value;
	int _nbChild;
	std::vector<GraphNode *> _children;
 
public:
	GraphNode(void);
	GraphNode(T value);
	GraphNode(const GraphNode &graphNode);
 
	void AddChild(GraphNode *graphNode);
	void DrawGraphNode();
 
	GraphNode &operator=(const GraphNode& graphNode);
 
	~GraphNode(void);
 
 
	//getter
	const T								GetValue()			const {return _value;}
	const int							GetNbChild()		const {return _nbChild;}
	const GraphNode<T> *				GetChild(int i)		const {return _children[i];}
	const std::vector<GraphNode<T> *>	GetChildren()		const {return _children;}
 
	//setter
	void SetValue(T value){_value = value;}
	void SetChild(GraphNode *graphNode, int i){_children[i] = graphNode;}
};
 
 
 
 
 
 
//================================DEFINITION DES FONCTIONS MEMBRES=====================
 
template<typename T>
GraphNode<T>::GraphNode(void)
{
	this->_value = (T)0;
	this->_nbChild = 0;
	this->_children = std::vector<GraphNode *>();
}
 
template<typename T>
GraphNode<T>::GraphNode(T value)
{
	this->_value = value;
	this->_nbChild = 0;
	this->_children = std::vector<GraphNode *>();
}
 
template<typename T>
GraphNode<T>::GraphNode(const GraphNode<T>& graphNode)
{
	this->_value = graphNode->GetValue();
	this->_nbChild = graphNode->GetNbChild();
	if (graphNode->GetChildren() != NULL)
	{
		this->_children = new vector<GraphNode *>[this->_nbChild];
		for (int i=0; i<this->_nbChild; ++i)
			this->_children.push_back(graphNode->GetChild(i));
	}
}
 
template<typename T>
void GraphNode<T>::AddChild(GraphNode<T> *graphNode)
{
	++this->_nbChild;
	this->_children.push_back(graphNode);
}
 
template<typename T>
void GraphNode<T>::DrawGraphNode()
{
	for (int i=0; i<this->_nbChild; ++i)
	{
		std::cout << "______";
		if (i == this->_nbChild/2)
			std::cout << _value;
	}
	std::cout << std::endl;
	for (int i=0; i<this->_nbChild; ++i)
		std::cout << "|      ";
	for (int i=0; i<this->_nbChild; ++i)
		std::cout << _children[i]->GetValue();
}
 
template<typename T>
GraphNode<T> &GraphNode<T>::operator=(const GraphNode<T> &graphNode)
{
	this->_value = graphNode->GetValue();
	this->_nbChild = graphNode->GetNbChild();
	if (graphNode->GetChildren() != NULL)
	{
		if (this->_children != NULL)
			delete[] this->_children;
		this->_children = new GraphNode*[this->_nbChild];
		for (int i=0; i<this->_nbChild; ++i)
			this->_children[i] = graphNode->GetChild(i);
	}
}
 
template<typename T>
GraphNode<T>::~GraphNode(void)
{
	for (int i=0; i<this->_nbChild; i++)
		delete this->_children[i];
}
 
 
#endif

Si je ne met rien dans le destructeur Avast ne me recommande pas ce programme. Si je met ma boucle j'ai un joli : "Debug Assertion Failed"


Merci d'avance,
Robin