From: george.priv@gmail.com
Subject: Re: What's wrong with my code?
Date: Mon, 28 Apr 2008 08:23:10 -0700 (PDT)
Date: 2008-04-28T08:23:10-07:00 [thread overview]
Message-ID: <f0e935bf-8dae-4181-845a-6cf0864bbe1a@x35g2000hsb.googlegroups.com> (raw)
In-Reply-To: 5a3b83ab-c9eb-448d-8e01-093df11bd3d2@b1g2000hsg.googlegroups.com
On Apr 28, 10:42 am, amal.alpho...@gmail.com wrote:
> Sorry if I'm posting in the wrong forum.
>
> I have a generic package, with specification:
>
> generic
> type Element is private;
> with procedure Element_Put(E : in Element);
> package SelectionP is
> type My_Array is array (0..10) of Element;
> Max : constant Integer := 10;
> procedure Find_Min (A : My_Array; Offset : Integer; Pos : Integer);
> procedure Swap (A : in out My_Array; First : Integer; Second :
> Integer);
> procedure Sort (A : in out My_Array);
> procedure Print (A : in My_Array);
> end SelectionP;
> --------------------------------------------------
> and its package body is:
>
> package body SelectionP is
>
> A : My_Array;
>
> procedure Find_Min (A : My_Array; Offset : Integer; Pos : Integer)
> is
> ...
> end Find_Min;
>
> procedure Swap (A : in out My_Array; First : Integer; Second :
> Integer) is
> ...
> end Swap;
>
> procedure Sort (A : in out My_Array) is
> ...
> end Sort;
> procedure Print (A: in out My_Array) is
> ...
> end Print;
>
> end SelectionP;
> -------------------------------------------
>
> And I try to make use of this package in this file:
> with Ada.Text_IO, Ada.Integer_Text_IO;
> with SelectionP;
> procedure SelectionPUser is
> package IntSelectionP is new SelectionP(Integer, Ada.Text_IO.Put);
should be:
package IntSelectionP is new SelectionP(Integer,
Ada.Integer_Text_IO.Put);
> begin
> Ada.Text_IO.New_Line;
> end SelectionPUser;
>
> ---
>
> I try to compile but it says 'no visible subprogram matches the
> specification for Element_Put' referring to the line above where I
> make the new package IntSelectionP. I can't see what i've done wrong.
>
> Also, is my code correct if my purpose is to use the package to create
> arrays of different elements (integer, character, etc) and use the
> procedures Find_Min and Sort and Print on them?
For these types you should be fine. For more complex types you may
need to define "<" and "=" operators.
George.
>
> Thanks
next prev parent reply other threads:[~2008-04-28 15:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-28 14:42 What's wrong with my code? amal.alphonse
2008-04-28 15:18 ` stefan-lucks
2008-04-28 15:22 ` stefan-lucks
2008-04-28 15:24 ` stefan-lucks
2008-04-28 15:23 ` george.priv [this message]
2008-04-28 16:52 ` Ivan Levashew
2008-04-29 9:18 ` Ludovic Brenta
2008-04-29 5:30 ` christoph.grein
2008-04-29 9:31 ` Ludovic Brenta
2008-04-29 10:33 ` amal.alphonse
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox