Bonjour,
J'ai un problème d'embiguïté avec la POO à l'appel d'une fonction avec la fonction abstraite.
Voici mon code :
Code :
-- Digializer 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 :
package Digitalizer is pragma Pure (Digitalizer); end Digitalizer;
|
Code :
with Interfaces.C; use Interfaces; package Digitalizer.MIDI is type MIDI_Name_Type is (VirusTI2); end Digitalizer.MIDI;
|
Code :
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 :
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 :
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 :
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 :
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 :
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 me répond ceci :
Citation :
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
|
Merci pour votre investissement.
Message édité par Profil supprimé le 25-09-2015 à 20:31:29