From: "IVAN DE JESUS DERAS TABORA" <i.deras@unitec.edu>
To: rafael@thinkfreak.com.br
Cc: Voicu Liviu <pacman@mscc.huji.ac.il>,
Sandro Dangui <sdangui@nortelnetworks.com>,
linux-c-programming@vger.kernel.org
Subject: Re: C++ class inheritance
Date: Fri, 03 Oct 2003 15:18:23 -0600 [thread overview]
Message-ID: <1460d043642d73d6.642d73d61460d043@unitec.edu> (raw)
Templates are like a C macros, but templates provide a more elegant form
to do things that normally you could do with C macros, in some way.
For example:
template <class T>
struct MyStruct
{ int x, y;
T* ptr;
}
Now you could define vars in C++:
MyStruct<int> myVar1OfTypeMyStruct;
MyStruct<float> myVar2OfTypeMyStruct;
You could do almot the same in C:
#define MyStructType(T) typedef struct { \
int x, y; \
T* ptr; \
} MyStruct_##T \
MyStruct(int);
MyStruct(float);
Now you could define vars in C like this:
MyStruct_int myVar1OfTypeMyStruct;
MyStruct_float myVar1OfTypeMyStruct;
A i said before is more elegant the C++ form!!!!!!!!!!!
----- Original Message -----
From: Rafael Costa dos Santos <rafael@thinkfreak.com.br>
Date: Friday, October 3, 2003 6:57 am
Subject: Re: C++ class inheritance
> Ok, but as I am C ANSI programmer it is a bit dificult to underestand.
>
> Are you saying that "RasPDU" is a general class that depends on the
> template
> (in this case "H225_RegistrationRequest") that is informed ?
>
> Is it similar to create a specific class like:
>
> class RasPDU : public H225_RegistrationRequest
> {
> } ;
>
> and inherit from it ?
>
> class RegistrationRequestPDU : public RasPDU
> {
> } ;
>
> On Thursday 02 October 2003 07:30, Voicu Liviu wrote:
> > Rafael Costa dos Santos wrote:
> > >Can anyone explain me what does < > means ?
> > >Example:
> > >
> > >class RegistrationRequestPDU : public
> RasPDU<H225_RegistrationRequest>> >{
> > >} ;
> > >
> > >Is "RegistrationRequestPDU" inheriting from RasPDU,
> > > H225_RegistrationRequest or both ?
> >
> > RegistrationRequestPDU inherits from RasPDU using template
> > H225_RegistrationRequest ?
>
> --
> Rafael Costa dos Santos
> rafael@thinkfreak.com.br
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-
> programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
next reply other threads:[~2003-10-03 21:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-03 21:18 IVAN DE JESUS DERAS TABORA [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-10-02 12:27 C++ class inheritance Sandro Dangui
2003-10-02 4:00 Rafael Costa dos Santos
2003-10-02 7:30 ` Voicu Liviu
2003-10-03 12:57 ` Rafael Costa dos Santos
2003-10-03 16:19 ` Darío Mariani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1460d043642d73d6.642d73d61460d043@unitec.edu \
--to=i.deras@unitec.edu \
--cc=linux-c-programming@vger.kernel.org \
--cc=pacman@mscc.huji.ac.il \
--cc=rafael@thinkfreak.com.br \
--cc=sdangui@nortelnetworks.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).