From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,308a261188818cce X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!x40g2000prg.googlegroups.com!not-for-mail From: shaunpatterson@gmail.com Newsgroups: comp.lang.ada Subject: Re: Pointers explained? Date: Mon, 30 Jul 2007 10:56:29 -0700 Organization: http://groups.google.com Message-ID: <1185818189.689914.159900@x40g2000prg.googlegroups.com> References: <1185817996.143086.317990@g12g2000prg.googlegroups.com> NNTP-Posting-Host: 155.219.241.10 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1185818190 3395 127.0.0.1 (30 Jul 2007 17:56:30 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 30 Jul 2007 17:56:30 +0000 (UTC) In-Reply-To: <1185817996.143086.317990@g12g2000prg.googlegroups.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.0.04506.30; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: x40g2000prg.googlegroups.com; posting-host=155.219.241.10; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Xref: g2news2.google.com comp.lang.ada:1272 Date: 2007-07-30T10:56:29-07:00 List-Id: ------- OKAY sorry... I tried to tab in and accidentally activated the POST button ---- Hi I'm still relatively new to Ada -- coming from a strong C++ background. Some of this may seem stupid - and feel free to point it out to me. I am using Ada 95 - GNAT Pro 3.16a1 I have a message factory I've been screwing around with (converting it from Ada to C++). I basically have an abstract message type: type Message is abstract tagged null record; type Message_Class is access all Message'Class; then all other messages are derived from this. Now from my factory create method, I'm returning a Message_Class. This message_class is stored in another record to be handled again later: type CallbackEvent is record msg : Message_Class; ... end record; Now my basic problem -- or not really a problem -- is that to create the Message_Class I have to use "new" and allocate and deallocate memory. Now - my solution was to re-write my message factory to return a type Message'Class. However, I went to change my callback structure to: type CallbackEvent is record msg : Message'Class end record; and I get the message "unconstrained subtype in component declaration" So, I'm assuming the compiler just doesn't know how to big this message is. that's why I believe i should use a pointer (the Message_Class type) However, I cannot find a way of converting between a Message'Class to a Message_Class; It appears that the only way to get a Message_Class is by some where in the code using a "new" Is this assumption correct? thanks! -- Shaun