From: "Steve Doiel" <nospam_steved94@attbi.com>
Subject: Re: Package instance???
Date: Thu, 14 Feb 2002 02:54:03 GMT
Date: 2002-02-14T02:54:03+00:00 [thread overview]
Message-ID: <fFFa8.54055$AV5.312647@rwcrnsc51.ops.asp.att.net> (raw)
In-Reply-To: OvBYEeMtBHA.1400@cpimsnntpa03
"Yates" <yates_1900@yahoo.com> wrote in message
news:OvBYEeMtBHA.1400@cpimsnntpa03...
> I am new to Ada. I'd like to know if it is possible to create multiple
> instances of a package. For example, if I have a package 'My_Package',
can
> I do something like:
>
> p1 : My_Package := new My_Package
> p2 : My_Package := new My_Package
> .....
>
> I tried this and didn't work. Is there other ways to do it?
>
Just to round out the discussion, yes you can do something kind of like
that, but that's probably not what your really want....
If your current package is defined as:
package My_Package is
... your package spec declarations here
end My_Package;
package body My_Package is
... your package implementation code here
end My_Package;
You can change your package spec to:
generic
package My_Package is
... your package spec declarations here
end My_Package;
And then you can define:
p1 is new My_Package;
p2 is new My_Package;
Which will create two instances of a My_Package.
I don't know your background, but if you have C++ for comparison a generic
in Ada is kind of like a template in C++, not an object.
I hope this helps,
SteveD
> Thanks
>
> Yates
>
>
next prev parent reply other threads:[~2002-02-14 2:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-13 19:48 Package instance??? Yates
2002-02-13 22:25 ` Zach Swanson
2002-02-13 22:31 ` Jeffrey Carter
2002-02-14 2:28 ` Zach Swanson
2002-02-14 14:32 ` Marin David Condic
2002-02-14 2:04 ` Bobby D. Bryant
2002-02-14 2:54 ` Steve Doiel [this message]
2002-02-14 14:41 ` Marin David Condic
2002-02-15 2:13 ` Steve Doiel
2002-02-14 12:48 ` Marc A. Criley
2002-02-14 15:09 ` Yates
2002-02-14 18:12 ` Matthew Heaney
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox