Bonjour, j'ai un problème avec la POO, je pige pas l'erreur vu le fonctionnement du langage.
l'erreur est un problème d'ambiguïté avec une fonction abstraite !
Voici mon code.
Code ada : 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 -- Digitalizer is small virtual MIDI composer. -- Digitalizer Copyright 2015 (C) Manuel De Girardi. with Ada.Text_Io; with Ada.Integer_Text_Io; use Ada; with Digitalizer.MIDI.GM_Instruments; with Digitalizer.MIDI.GM_Instruments.Virus; use Digitalizer.MIDI.GM_Instruments; use Digitalizer.MIDI.GM_Instruments.Virus; use Digitalizer; with Digitalizer.Composer; procedure Main is begin declare VirusTI2 : VirusTI2_Type; package Composer is new Digitalizer.Composer(GM_Instrument => VirusTI2); begin Text_Io.Put_Line("GM Instrument Id : "); Integer_Text_Io.Put(Composer.Instrument_Id); Text_Io.New_Line; end; end Main;
Code ada : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 package Digitalizer is pragma Pure (Digitalizer); end Digitalizer;
Code ada : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 with Interfaces.C; use Interfaces; package Digitalizer.MIDI is type MIDI_Name_Type is (VirusTI2); end Digitalizer.MIDI;
Code ada : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 package Digitalizer.MIDI.GM_Instruments is type GM_Instrument_Type(MIDI_Name : MIDI_Name_Type) is abstract tagged record null; end record; function Instrument_Id (GM_Instrument : in GM_Instrument_Type'Class) return Integer is abstract; end Digitalizer.MIDI.GM_Instruments;
Code ada : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 package Digitalizer.MIDI.GM_Instruments.Virus is type VirusTI2_Type is new GM_Instrument_Type(VirusTI2) with record Identifiant : Integer := 0; end record; function Instrument_Id (VirusTI : in VirusTI2_Type) return Integer; end Digitalizer.MIDI.GM_Instruments.Virus;
Code ada : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 package body Digitalizer.MIDI.GM_Instruments.Virus is function Instrument_Id (VirusTI : in VirusTI2_Type'Class) return Integer is begin return VirusTI.Identifiant; end Instrument_Id; end Digitalizer.MIDI.GM_Instruments.Virus;
Code ada : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 with Digitalizer.MIDI.GM_Instruments; use Digitalizer.MIDI; generic GM_Instrument : MIDI.GM_Instruments.GM_Instrument_Type 'Class; package Digitalizer.Composer is function Instrument_Id return Integer; end Digitalizer.Composer;
Code ada : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 with Digitalizer.MIDI.GM_Instruments.Virus; use Digitalizer.MIDI.GM_Instruments.Virus; package body Digitalizer.Composer is function Instrument_Id return Integer is begin case Gm_Instrument.MIDI_Name is when VirusTI2 => return VirusTI2_Type(GM_Instrument).Instrument_Id; when others => raise Program_Error; end case; end Instrument_Id; end Digitalizer.Composer;
Gnat dit :
gnatmake src/main -o bin/digitalizer -D obj -aIsrc/lib -lportmidi -lporttime
gcc-4.9 -c -Isrc/ -Isrc/lib -lportmidi -lporttime -I- -o /home/manu/Digitalizer/obj/main.o src/main.adb
digitalizer-composer.adb:9:48: ambiguous expression (cannot resolve "Instrument_Id")
digitalizer-composer.adb:9:48: possible interpretation at digitalizer-midi-gm_instruments-virus.ads:8
digitalizer-composer.adb:9:48: possible interpretation at digitalizer-midi-gm_instruments.ads:10
gnatmake: "src/main.adb" compilation error
Partager