comp.lang.ada
 help / color / mirror / Atom feed
From: matthew_heaney@acm.org (Matthew Heaney)
Subject: Re: problem with operation
Date: 1998/05/09
Date: 1998-05-09T00:00:00+00:00	[thread overview]
Message-ID: <matthew_heaney-ya023680000905981526140001@news.ni.net> (raw)
In-Reply-To: 01bc5cbd$c4565da0$LocalHost@default


In article <01bc5cbd$c4565da0$LocalHost@default>, "Bernhard Rumpler"
<b.rumpler@gmx.net> wrote:

(start of quote)
I don't know how to use the operation "+" with a private type. 
("left operand has private type "Element_Typ" defined at
Matrizen_Operationen.ads, right operand has.." ..the same type) I simply
want to add the Operands as if they were of type Integer, real or sth. like
that.

GENERIC
  TYPE Element_Typ IS PRIVATE;
(end of quote)

Here is your problem.  You haven't imported addition of elements as a
operation.  So do this:

   with function "+" 
      (L, R : Element_Type) return Element_Type is <>;

(start of quote)
  Z_S_Zahl : NATURAL;
  
PACKAGE Matrizen_Operationen IS

  TYPE Matrix IS PRIVATE;
 
  
  FUNCTION "+" (M1,M2: IN Matrix)RETURN Matrix;
  FUNCTION "*" (M1,M2: IN Matrix)RETURN Matrix;

  PRIVATE
    TYPE Matrix IS ARRAY (1..Z_S_Zahl, 1..Z_S_Zahl)OF Element_Typ;
  
END Matrizen_Operationen;    
    
PACKAGE BODY Matrizen_Operationen IS

  
  FUNCTION "+" (M1,M2: IN Matrix) RETURN Matrix IS
  i,j: INTEGER;
  M3: Matrix;
  BEGIN
    FOR i IN 1..Z_S_Zahl LOOP
      FOR j IN 1..Z_S_Zahl LOOP
        M3(i,j) := M1(i,j)+M2(i,j); -- <-- HERE!!!!
      END LOOP;
    END LOOP; 
  RETURN M3;
  END;

  FUNCTION "*" (M1,M2: IN Matrix) RETURN Matrix IS
  M3: Matrix;
  BEGIN
    RETURN M3; 
  END;
  
END Matrizen_Operationen;  
(end of quote)




      parent reply	other threads:[~1998-05-09  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-05-09  0:00 problem with operation Bernhard Rumpler
1998-05-09  0:00 ` Michael F Brenner
1998-05-09  0:00   ` Robert Dewar
1998-05-09  0:00 ` Matthew Heaney [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox