Bonjour,
Me re-voici avec une nouvelle question sur les classes .
Si on part de ce code qui marche:
Si je change la decalartion que ma class en marquant (cf parti en rouge):
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 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Déclarations privées } public { Déclarations publiques } end; type Tdata = class private Int:LongInt; Reel:double; Text:string; published property v : LongInt read Int write Int; //overload; //property Value : double read ReadDouble write WriteDouble; overload; //property Value : string read ReadString write WriteString; overload; public constructor Create; destructor Destroy; public procedure SetInt(value: LongInt); // procedure SetDouble(value: Double); // procedure SetString(value: String); end; var Form1: TForm1; D: Tdata; implementation {$R *.dfm} constructor Tdata.Create(); begin Int:=0; Reel:=0; Text:='0'; end; destructor Tdata.Destroy; begin end; procedure Tdata.SetInt(value: LongInt); begin Int:=value; Reel:= value; Text:=inttostr(value); end; procedure TForm1.Button1Click(Sender: TObject); begin Button1.Caption:='OK'; D:=Tdata.Create; D.SetInt(6); end; end.
Delphi me jete avec le message d'erreur:
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 type Tdata = class private Int:LongInt; Reel:double; Text:string; published property v : LongInt read Int write SetInt; //overload; //property v : double read ReadDouble write WriteDouble; overload; //property v : string read ReadString write WriteString; overload; public constructor Create; destructor Destroy; public procedure SetInt(value: LongInt); // procedure SetDouble(value: Double); // procedure SetString(value: String); end;
[Erreur] Unit1.pas(26): Identificateur de champ ou de méthode attendu
Je ne comprends vraiment pas pourquoi... quelqu'un peut il me dire ce qui cloche dans ma déclaration?
Aprés j'ai une deuxième question: peux t-on faire un overload sur une property ?
Partager