comp.lang.ada
 help / color / mirror / Atom feed
* oo programing question
@ 2003-12-06 19:01 shoko
  2003-12-06 20:18 ` Stephen Leake
  2003-12-07 14:01 ` Martin Krischik
  0 siblings, 2 replies; 5+ messages in thread
From: shoko @ 2003-12-06 19:01 UTC (permalink / raw)


i have the following code:

package a is
  --car class --
  type a is tagged private; 
  type a_ptr is access all car'class;
  
  --car methods --
   private
     type a is tagged 
     record
         name:String(1..256);
     end record;
  
   
end a;
-------------------------------------

with a;

package b is
   type b is new a.a with private;   <--  constraint error 
   type b_Ptr is access all b'Class;

   function init_b(maximum:positive) return b_Ptr;
  
  private
     type b is new  a.awith
     record
         maximum_:positive;
     end record;
end b;
-------------------------------------------
in the main procedure:

with a;use a;
with b;use b;

procedure main is
   new_b:b_ptr;
     
begin
    new_b := init_b(90);
 end main;

i get constraint error on b.ads
i dont understand why

please help



^ permalink raw reply	[flat|nested] 5+ messages in thread
* oo programing question
@ 2003-12-07 21:14 shoko
  2003-12-08 19:04 ` Martin Krischik
  0 siblings, 1 reply; 5+ messages in thread
From: shoko @ 2003-12-07 21:14 UTC (permalink / raw)


here is my generic package:
generic
   type Element_Type is private;

   package queue is
     type Queue  is abstract tagged private; 
     
     type newqueue is new Queue ;<-- how to create new queue type?
     
     procedure Init( Q: in out Queue) is abstract;

     private
         type Queue is  abstract tagged 
           record
              value:Element_Type;
           end record;
   
   end queue; 

i need to create a new abstract type(newqueue) that will inherit from Queue.

  
then need to put the new type(newqueue) in the same generic Queue package,
and to add a new method to the new abstract type.

the reason that the new abstract type(newqueue) should be in the same package is:
i have a type that inherit from Queue  
and now i need a new type that inherit from the new abstract type (newqueue)
and will be the same as the one that inherit from Queue.

how can i do it?

thanks



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-12-08 19:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-06 19:01 oo programing question shoko
2003-12-06 20:18 ` Stephen Leake
2003-12-07 14:01 ` Martin Krischik
  -- strict thread matches above, loose matches on Subject: below --
2003-12-07 21:14 shoko
2003-12-08 19:04 ` Martin Krischik

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