bonjour à tous

je ne comprend pas pourquoi il refuse ma classe enregistrement (je ne connais pas bien shared_ptr)

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
enregistrements.hpp
#ifndef enregistrements_hpp
#define enregistrements_hpp
 
#include "commun.hpp"
 
#include <string>
#include <vector>
enum class type{Taction,Tterminal,TnonTerminal,Tsynthese};
enum class typeSynthese{synthC,synthA1,synthAprim,synthA2,
			synthB,synthBprim};
 
class enregistrement{
public:
  virtual void affiche();
  virtual type quelType();
  virtual int getActionSemantique();
  virtual void setActionSemantique(int const &x);
  virtual SYMBOLE getSymbole();
  virtual void setSymbole(SYMBOLE const &x);
  virtual bool vaut(ULEX const &a);
  virtual bool estTerminal();
  virtual void ajoute(std::string const &x);
  virtual typeSynthese getNomSynthese();
  virtual void setNomSynthese(typeSynthese const &x);
};
 
class action:public enregistrement{
public:
  void affiche();
  type quelType();// retourne toujours Taction
  std::string getA(int const &i);
  void setA(int const &i,std::string const &x);
  void ajoute(std::string const &x);
  int getActionSemantique();
  void setActionSemantique(int const &x);
private:
  int actionSemantique;
  std::vector<std::string> Attr;
};
 
class terminal:public enregistrement{
public:
  void affiche();
  type quelType();// retourne toujours Tterminal
  bool vaut(ULEX const &a);
  bool estTerminal();//retourne toujours true
  int getActionSemantique();//retourne toujours 0
  void setSymbole(SYMBOLE const &x);
  SYMBOLE getSymbole();
  std::string symbole2string();
private:
  SYMBOLE X;
  ULEX term;
};
 
class nonTerminal:public enregistrement{
public:
  void affiche();
  type quelType();// retourne toujours TnonTerminal
  void setSymbole(SYMBOLE const &x);
  SYMBOLE getSymbole();
  int getActionSemantique();//retourne toujours 0
  std::string getHerite(int i);
  void setHerite(int const &i,std::string const &x);
  void ajoute(std::string const &x);
  bool estTerminal();//retourne toujours false;
  std::string symbole2string();
private:
  SYMBOLE X;
  std::vector<std::string>herite;
};
 
class synthese:public enregistrement{
public:
  void affiche();
  type quelType();// retourne toujours Tsynthèse
  typeSynthese getNomSynthese();
  void setNomSynthese(typeSynthese const &x);
  std::string getA(int i);
  void setA(int const &i,std::string const &x);
  void ajoute(std::string const &x);
  int getActionSemantique();
  void setActionSemantique(int const &x);
  std::string symbole2string();
private:
  std::vector<std::string>Attr;
  int actionSemantique;
  typeSynthese nomSynthese;
};
#endif
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
syntaxique.cpp
#include <memory>
#include <iostream>
#include "syntaxique.hpp"
#include "enregistrements.hpp"
 
syntaxique::syntaxique(std::string const &nomFichier):pe(nomFichier){
  std::shared_ptr<enregistrement>E;
  E=std::make_shared<enregistrement>(new terminal);
  E->setSymbole(SYMBOLE::dolar);
  pile.push_back(E);
  E=std::make_shared<enregistrement>(new nonTerminal);
  E->setSymbole(SYMBOLE::C);
  pile.push_back(E);
  E=std::make_shared<enregistrement>(new synthese);
  E->setNomSynthese(typeSynthese::synthC);
  E->ajoute("");
  E->ajoute("");
  pile.push_back(E);
}
 
void syntaxique::anaSynt(){
  uniLex l;
  l=pe.anaLex();
  a=l.getLex();
  X=std::make_shared<enregistrement>(pile[pile.size()-1]);
  while( ! X->vaut(ULEX::dolar)){
    if(X->vaut(a)){
      pile.pop_back();
      l=pe.anaLex();
      a=l.getLex();
    }
    else if(X->estTerminal())
      if(a==ULEX::dolar){
	std::cerr<<"Fichier source inachevé"<<std::endl;
	exit(1);
      }
      else{
	std::cerr<<l.getLexeme()<<" inattendu"<<std::endl;
	l=pe.anaLex();
	a=l.getLex();
      }
    switch(X->getSymbole()){
    case SYMBOLE::C:
      if(a==ULEX::a){
	//inachevé
      }
    }
  }
}
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
$ g++ -c syntaxique.cpp
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/memory:63,
                 from syntaxique.cpp:1:
/usr/include/c++/9/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = enregistrement; _Args = {terminal*}; _Tp = enregistrement]’:
/usr/include/c++/9/bits/alloc_traits.h:482:2:   required from ‘static void std::allocator_traits<std::allocator<_Tp1> >::construct(std::allocator_traits<std::allocator<_Tp1> >::allocator_type&, _Up*, _Args&& ...) [with _Up = enregistrement; _Args = {terminal*}; _Tp = enregistrement; std::allocator_traits<std::allocator<_Tp1> >::allocator_type = std::allocator<enregistrement>]’
/usr/include/c++/9/bits/shared_ptr_base.h:548:39:   required from ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_Sp_counted_ptr_inplace(_Alloc, _Args&& ...) [with _Args = {terminal*}; _Tp = enregistrement; _Alloc = std::allocator<enregistrement>; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’
/usr/include/c++/9/bits/shared_ptr_base.h:679:16:   required from ‘std::__shared_count<_Lp>::__shared_count(_Tp*&, std::_Sp_alloc_shared_tag<_Alloc>, _Args&& ...) [with _Tp = enregistrement; _Alloc = std::allocator<enregistrement>; _Args = {terminal*}; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’
/usr/include/c++/9/bits/shared_ptr_base.h:1344:71:   required from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<enregistrement>; _Args = {terminal*}; _Tp = enregistrement; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’
/usr/include/c++/9/bits/shared_ptr.h:359:59:   required from ‘std::shared_ptr<_Tp>::shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<enregistrement>; _Args = {terminal*}; _Tp = enregistrement]’
/usr/include/c++/9/bits/shared_ptr.h:701:14:   required from ‘std::shared_ptr<_Tp> std::allocate_shared(const _Alloc&, _Args&& ...) [with _Tp = enregistrement; _Alloc = std::allocator<enregistrement>; _Args = {terminal*}]’
/usr/include/c++/9/bits/shared_ptr.h:717:39:   required from ‘std::shared_ptr<_Tp> std::make_shared(_Args&& ...) [with _Tp = enregistrement; _Args = {terminal*}]’
syntaxique.cpp:8:50:   required from here
/usr/include/c++/9/ext/new_allocator.h:145:20: error: no matching function for call to ‘enregistrement::enregistrement(terminal*)145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from syntaxique.hpp:8,
                 from syntaxique.cpp:3:
enregistrements.hpp:12:7: note: candidate: ‘constexpr enregistrement::enregistrement()12 | class enregistrement{
      |       ^~~~~~~~~~~~~~
enregistrements.hpp:12:7: note:   candidate expects 0 arguments, 1 provided
enregistrements.hpp:12:7: note: candidate: ‘constexpr enregistrement::enregistrement(const enregistrement&)’
enregistrements.hpp:12:7: note:   no known conversion for argument 1 from ‘terminal*’ to ‘const enregistrement&’
enregistrements.hpp:12:7: note: candidate: ‘constexpr enregistrement::enregistrement(enregistrement&&)’
enregistrements.hpp:12:7: note:   no known conversion for argument 1 from ‘terminal*’ to ‘enregistrement&&’
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/memory:63,
                 from syntaxique.cpp:1:
/usr/include/c++/9/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = enregistrement; _Args = {nonTerminal*}; _Tp = enregistrement]’:
/usr/include/c++/9/bits/alloc_traits.h:482:2:   required from ‘static void std::allocator_traits<std::allocator<_Tp1> >::construct(std::allocator_traits<std::allocator<_Tp1> >::allocator_type&, _Up*, _Args&& ...) [with _Up = enregistrement; _Args = {nonTerminal*}; _Tp = enregistrement; std::allocator_traits<std::allocator<_Tp1> >::allocator_type = std::allocator<enregistrement>]’
/usr/include/c++/9/bits/shared_ptr_base.h:548:39:   required from ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_Sp_counted_ptr_inplace(_Alloc, _Args&& ...) [with _Args = {nonTerminal*}; _Tp = enregistrement; _Alloc = std::allocator<enregistrement>; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’
/usr/include/c++/9/bits/shared_ptr_base.h:679:16:   required from ‘std::__shared_count<_Lp>::__shared_count(_Tp*&, std::_Sp_alloc_shared_tag<_Alloc>, _Args&& ...) [with _Tp = enregistrement; _Alloc = std::allocator<enregistrement>; _Args = {nonTerminal*}; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’
/usr/include/c++/9/bits/shared_ptr_base.h:1344:71:   required from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<enregistrement>; _Args = {nonTerminal*}; _Tp = enregistrement; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’
/usr/include/c++/9/bits/shared_ptr.h:359:59:   required from ‘std::shared_ptr<_Tp>::shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<enregistrement>; _Args = {nonTerminal*}; _Tp = enregistrement]’
/usr/include/c++/9/bits/shared_ptr.h:701:14:   required from ‘std::shared_ptr<_Tp> std::allocate_shared(const _Alloc&, _Args&& ...) [with _Tp = enregistrement; _Alloc = std::allocator<enregistrement>; _Args = {nonTerminal*}]’
/usr/include/c++/9/bits/shared_ptr.h:717:39:   required from ‘std::shared_ptr<_Tp> std::make_shared(_Args&& ...) [with _Tp = enregistrement; _Args = {nonTerminal*}]’
syntaxique.cpp:11:53:   required from here
/usr/include/c++/9/ext/new_allocator.h:145:20: error: no matching function for call to ‘enregistrement::enregistrement(nonTerminal*)145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from syntaxique.hpp:8,
                 from syntaxique.cpp:3:
enregistrements.hpp:12:7: note: candidate: ‘constexpr enregistrement::enregistrement()12 | class enregistrement{
      |       ^~~~~~~~~~~~~~
enregistrements.hpp:12:7: note:   candidate expects 0 arguments, 1 provided
enregistrements.hpp:12:7: note: candidate: ‘constexpr enregistrement::enregistrement(const enregistrement&)’
enregistrements.hpp:12:7: note:   no known conversion for argument 1 from ‘nonTerminal*’ to ‘const enregistrement&’
enregistrements.hpp:12:7: note: candidate: ‘constexpr enregistrement::enregistrement(enregistrement&&)’
enregistrements.hpp:12:7: note:   no known conversion for argument 1 from ‘nonTerminal*’ to ‘enregistrement&&’
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/memory:63,
                 from syntaxique.cpp:1:
/usr/include/c++/9/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = enregistrement; _Args = {synthese*}; _Tp = enregistrement]’:
/usr/include/c++/9/bits/alloc_traits.h:482:2:   required from ‘static void std::allocator_traits<std::allocator<_Tp1> >::construct(std::allocator_traits<std::allocator<_Tp1> >::allocator_type&, _Up*, _Args&& ...) [with _Up = enregistrement; _Args = {synthese*}; _Tp = enregistrement; std::allocator_traits<std::allocator<_Tp1> >::allocator_type = std::allocator<enregistrement>]’
/usr/include/c++/9/bits/shared_ptr_base.h:548:39:   required from ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_Sp_counted_ptr_inplace(_Alloc, _Args&& ...) [with _Args = {synthese*}; _Tp = enregistrement; _Alloc = std::allocator<enregistrement>; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’
/usr/include/c++/9/bits/shared_ptr_base.h:679:16:   required from ‘std::__shared_count<_Lp>::__shared_count(_Tp*&, std::_Sp_alloc_shared_tag<_Alloc>, _Args&& ...) [with _Tp = enregistrement; _Alloc = std::allocator<enregistrement>; _Args = {synthese*}; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’
/usr/include/c++/9/bits/shared_ptr_base.h:1344:71:   required from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<enregistrement>; _Args = {synthese*}; _Tp = enregistrement; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’
/usr/include/c++/9/bits/shared_ptr.h:359:59:   required from ‘std::shared_ptr<_Tp>::shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<enregistrement>; _Args = {synthese*}; _Tp = enregistrement]’
/usr/include/c++/9/bits/shared_ptr.h:701:14:   required from ‘std::shared_ptr<_Tp> std::allocate_shared(const _Alloc&, _Args&& ...) [with _Tp = enregistrement; _Alloc = std::allocator<enregistrement>; _Args = {synthese*}]’
/usr/include/c++/9/bits/shared_ptr.h:717:39:   required from ‘std::shared_ptr<_Tp> std::make_shared(_Args&& ...) [with _Tp = enregistrement; _Args = {synthese*}]’
syntaxique.cpp:14:50:   required from here
/usr/include/c++/9/ext/new_allocator.h:145:20: error: no matching function for call to ‘enregistrement::enregistrement(synthese*)145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from syntaxique.hpp:8,
                 from syntaxique.cpp:3:
enregistrements.hpp:12:7: note: candidate: ‘constexpr enregistrement::enregistrement()12 | class enregistrement{
      |       ^~~~~~~~~~~~~~
enregistrements.hpp:12:7: note:   candidate expects 0 arguments, 1 provided
enregistrements.hpp:12:7: note: candidate: ‘constexpr enregistrement::enregistrement(const enregistrement&)’
enregistrements.hpp:12:7: note:   no known conversion for argument 1 from ‘synthese*’ to ‘const enregistrement&’
enregistrements.hpp:12:7: note: candidate: ‘constexpr enregistrement::enregistrement(enregistrement&&)’
enregistrements.hpp:12:7: note:   no known conversion for argument 1 from ‘synthese*’ to ‘enregistrement&&’
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/memory:63,
                 from syntaxique.cpp:1:
/usr/include/c++/9/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = enregistrement; _Args = {std::shared_ptr<enregistrement>&}; _Tp = enregistrement]’:
/usr/include/c++/9/bits/alloc_traits.h:482:2:   required from ‘static void std::allocator_traits<std::allocator<_Tp1> >::construct(std::allocator_traits<std::allocator<_Tp1> >::allocator_type&, _Up*, _Args&& ...) [with _Up = enregistrement; _Args = {std::shared_ptr<enregistrement>&}; _Tp = enregistrement; std::allocator_traits<std::allocator<_Tp1> >::allocator_type = std::allocator<enregistrement>]’
/usr/include/c++/9/bits/shared_ptr_base.h:548:39:   required from ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_Sp_counted_ptr_inplace(_Alloc, _Args&& ...) [with _Args = {std::shared_ptr<enregistrement>&}; _Tp = enregistrement; _Alloc = std::allocator<enregistrement>; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’
/usr/include/c++/9/bits/shared_ptr_base.h:679:16:   required from ‘std::__shared_count<_Lp>::__shared_count(_Tp*&, std::_Sp_alloc_shared_tag<_Alloc>, _Args&& ...) [with _Tp = enregistrement; _Alloc = std::allocator<enregistrement>; _Args = {std::shared_ptr<enregistrement>&}; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’
/usr/include/c++/9/bits/shared_ptr_base.h:1344:71:   required from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<enregistrement>; _Args = {std::shared_ptr<enregistrement>&}; _Tp = enregistrement; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’
/usr/include/c++/9/bits/shared_ptr.h:359:59:   required from ‘std::shared_ptr<_Tp>::shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<enregistrement>; _Args = {std::shared_ptr<enregistrement>&}; _Tp = enregistrement]’
/usr/include/c++/9/bits/shared_ptr.h:701:14:   required from ‘std::shared_ptr<_Tp> std::allocate_shared(const _Alloc&, _Args&& ...) [with _Tp = enregistrement; _Alloc = std::allocator<enregistrement>; _Args = {std::shared_ptr<enregistrement>&}]’
/usr/include/c++/9/bits/shared_ptr.h:717:39:   required from ‘std::shared_ptr<_Tp> std::make_shared(_Args&& ...) [with _Tp = enregistrement; _Args = {std::shared_ptr<enregistrement>&}]’
syntaxique.cpp:25:57:   required from here
/usr/include/c++/9/ext/new_allocator.h:145:20: error: no matching function for call to ‘enregistrement::enregistrement(std::shared_ptr<enregistrement>&)145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from syntaxique.hpp:8,
                 from syntaxique.cpp:3:
enregistrements.hpp:12:7: note: candidate: ‘constexpr enregistrement::enregistrement()12 | class enregistrement{
      |       ^~~~~~~~~~~~~~
enregistrements.hpp:12:7: note:   candidate expects 0 arguments, 1 provided
enregistrements.hpp:12:7: note: candidate: ‘constexpr enregistrement::enregistrement(const enregistrement&)’
enregistrements.hpp:12:7: note:   no known conversion for argument 1 from ‘std::shared_ptr<enregistrement>’ to ‘const enregistrement&’
enregistrements.hpp:12:7: note: candidate: ‘constexpr enregistrement::enregistrement(enregistrement&&)’
enregistrements.hpp:12:7: note:   no known conversion for argument 1 from ‘std::shared_ptr<enregistrement>’ to ‘enregistrement&&’
quelqu'un a une idée?