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: a07f3367d7,18684ed750c9b60f X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.224.183.13 with SMTP id ce13mr1444090qab.4.1349987113275; Thu, 11 Oct 2012 13:25:13 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.181.234 with SMTP id l70mr394505yhm.5.1349987113241; Thu, 11 Oct 2012 13:25:13 -0700 (PDT) Path: r17ni19491880qap.0!nntp.google.com!l8no45421948qao.0!postnews.google.com!m4g2000yqf.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 11 Oct 2012 13:25:13 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: m4g2000yqf.googlegroups.com; posting-host=157.127.124.14; posting-account=Trm_OQoAAABCO0PHK-TqWioYjr8e-azv NNTP-Posting-Host: 157.127.124.14 References: <51f8461d-d362-4e5f-a188-ac96a699a211@googlegroups.com> <527f8487-a578-406c-86c3-b3b0596cda71@l32g2000yqb.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; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC LM 8),gzip(gfe) Message-ID: Subject: Re: How to get generic formal parameter type into base class From: kevin andrew Injection-Date: Thu, 11 Oct 2012 20:25:13 +0000 Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-10-11T13:25:13-07:00 List-Id: Thanks Adam, Your solution is the workaround I had used. Ada is so strongly type cast I didn't think I would be able to do what I wanted. FYI, you can do this with C++ template classes, and though I have never tried, Java has added templates as well. C solution: #include using namespace std; typedef int value_t; template class baseClass { public: baseClass( ) { } void decode ( value_t value ) { } T getValue( void ) { } protected: T data; value_t value; private: }; template class newClass : public baseClass { public: newClass() { } void decode ( value_t value ) { this->value = value; this->data = (T)value; } T getValue( void ) { return this->data; } private: }; int main() { newClass intClass; newClass charClass; value_t value = 4; intClass.decode(value); int i = intClass.getValue(); value = 97; charClass.decode(value); char ch = charClass.getValue(); cout << "int=" << i << " ch=" << ch << endl; }