Bonjour,

voici du code pour montrer mon problème :

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
 
// la méthode ou ça plante
template<typename Type, typename Label>
void Automaton<Type,Label>::NewTransitionForState(const Label& name, Transition<Type,Label>* transition, State<Type,Label>* stateReached)
{
    for( auto s : statesVector )
        if ( s->GetName() == name )//<- ici la segmentation fault
            s->NewTransition(transition, stateReached);
 
    //s est normalement du type std::unique_ptr<Automaton<Type, Label>>
 
}
 
//le constructeur
template<typename Type, typename Label>
Automaton<Type,Label>::Automaton(const Label& name, const T_statesVector& statesVector) :
    statesVector(statesVector),
    name(name),
    up_currentState(nullptr)//<- si j'essayais d'y accéder tel quel je comprendrais
{
}
 
//création d'un nouvel état
template<typename Type, typename Label>
void Automaton<Type,Label>::NewState(State<Type,Label>* state)
{
    statesVector.push_back(state);
    if (up_currentState == nullptr)
        up_currentState = std::unique_ptr<State<Type, Label>>(state);//passera forcément par là, dailleurs j'avais aucun problème avec un pointeur classique
}
 
//la méthode qui appelle la méthode qui plante
using namespace std;
int compteur = 0;
cout << "->";
while(up_automaton->up_currentState->GetType() != StateType::finalState)
{
    cout << up_automaton->up_currentState->GetName() <<"(";
    const std::string& currentStateName = std::string(up_automaton->up_currentState->GetName());
    if (currentStateName == "Etat Initial")
    {
        cout << "test";
        compteur++;
        if (compteur==1000)
        {
            cout << up_automaton->up_currentState->GetTransitionByName("transition vers l'etat numero 3")->GetValue();
            up_automaton->UpdateState(up_automaton->up_currentState->GetTransitionByName("transition vers l'etat numero 3"));
        }
        else
        {
            cout << up_automaton->up_currentState->GetTransitionByName("transition vers l'etat numero 2")->GetValue();
            up_automaton->UpdateState(up_automaton->up_currentState->GetTransitionByName("transition vers l'etat numero 2"));
        }
    }
    else if (currentStateName == "Etat 2")
    {
        cout << up_automaton->up_currentState->GetTransitionByName("transition vers l'etat numero 4")->GetValue();
        up_automaton->UpdateState(up_automaton->up_currentState->GetTransitionByName("transition vers l'etat numero 4"));
    }
    else if (currentStateName == "Etat 3")
    {
        cout << up_automaton->up_currentState->GetTransitionByName("transition vers l'etat numero 5")->GetValue();
        up_automaton->UpdateState(up_automaton->up_currentState->GetTransitionByName("transition vers l'etat numero 5"));
    }
    else if (currentStateName == "Etat 4")
    {
        cout << up_automaton->up_currentState->GetTransitionByName("transition vers l'etat numero 1")->GetValue();
        up_automaton->UpdateState(up_automaton->up_currentState->GetTransitionByName("transition vers l'etat numero 1"));
    }
    else
        cout << L"nom de la transition : " << up_automaton->up_currentState->GetTransitionByName("transition vers l'etat numero 1")->GetName();
 
    cout << ") ->" << endl;
}
cout << up_automaton->up_currentState->GetName() << endl;
}
En l'état, il semblerait que je tape dans un objet non initialisé ou vide...

vous avez une explication ?

Merci d'avance pour votre aide.