Je développe une petite application objet,
je souhaite faire un enregistrement d'un tableau d'emprunts, mais lorsque j'appel ma fonction TLesEmprunt.creer() il me lance une erreur EAccessViolation...
J'ai d'autres classes qui fonctionnent exactement de la même manière (seuls les paramètres changents) mais je n'ai pas cette erreur.
Merci d'avance pour votre aide parce que la je sèche.
voici mon code
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
 
 
TEmprunt = class
private
CodeEmprunt:integer;
CodeEmprunteur:integer;
Media:string;
Titre:string;
DateEmprunt:string;
DateRetour:string;
public
  constructor creer(C,CE:integer;M,T,DE,DR:string);
  function getCodeEmprunt():integer;
  function getCodeEmprunteur():integer;
  function getMedia():string;
  function getTitre():string;
  function getDateEmprunt():string;
  function getDateRetour():string;
end;
 
TLesEmprunts = class
private
  LesEmprunts : TObjectList;
public
  constructor creer();
  procedure AjoutEmprunt(CA,CEA:integer;MA,TA,DEA,DRA:string);
  function getUnEmprunt(C:integer):TEmprunt;
  function countLesEmprunts():integer;
  function supprimerEmprunt(F:TEmprunt):boolean;
  function DonneNouveauCode():integer;
end;
 
constructor TEmprunt.creer(C,CE:integer;M,T,DE,DR:string);
begin
  inherited create();
  CodeEmprunt := C;
  CodeEmprunteur := CE;
  Media := M;
  Titre := T;
  DateEmprunt := DE;
  DateRetour := DR;
end;
 
constructor TLesEmprunts.creer();
begin
  LesEmprunts := TObjectList.Create();
end;
 
procedure TLesEmprunts.AjoutEmprunt(CA,CEA:integer;MA,TA,DEA,DRA:string);
var unEmprunt:TEmprunt;
begin
    unEmprunt.creer(CA,CEA,MA,TA,DEA,DRA); <--- Lerreur se situe ici...
    {LesEmprunts.Add(unEmprunt);}
end;