Article View: es.comp.os.linux.programacion
Article #10154Re: Herencia en C :-)
From: Enrique Arizón Benito
Date: Sun, 31 Mar 2002 22:39
Date: Sun, 31 Mar 2002 22:39
42 lines
1996 bytes
1996 bytes
Ra�l (Ridiculum) <Ridiculum@maxwell.tem.es> wrote in message news:<8il77a.qj.ln@127.0.0.1>...
> Estoy intentanto simular la herencia en C, al estilo de como lo hace
> GTK, pero tengo un problema con unos punterillos.
> Tengo una "clase" padre Bitmap y una "clase" hija JPEG que hereda de
> Bitmap:
> struct Bitmap {
> ....
> unsigned int uXres;
> };
> struct JPEG {
> struct Bitmap *pBitmap;
> ...
> };
>
Corrijeme si me equivoco pero para heredar JPEG de Bitmap deber�as
declarar JPEG como:
struct JPEG {
struct Bitmap Bitmap;
...
}
Con esto consigues que la representaci�n binaria que hace el
compilador de JPEG sea igual a la
de Bitmap (al menos los bytes inciales de JPEG) y por tanto al hacer
un casting
(Bitmap) jPeg_instancia.campo_bitmat
o bien
(Bitmap *) jPeg_ref->campo_bitmat
funcionar� correctamente.
Si por el contrario utilizas un puntero la representaci�n binaria de
JPEG por parte del compilador s�lo incluir� 4 bytes correspondientes a
un puntero.
Postdata: No utilices C++, es una ( -- censurado -- ). Lo mejor
glib/GTK+ o JAVA.
Technical Details
Message-ID:
<4eb64fb0.0203311439.3b1c2191@posting.google.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mailReferences:
<8il77a.qj.ln@127.0.0.1>Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII X-Google-Thread: f86c8,8b4d95dcaac031e0 X-Google-Attributes: gidf86c8,public X-Google-ArrivalTime: 2002-03-31 14:39:16 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail From: e_arizon_benito@yahoo.com (Enrique Arizón Benito) Newsgroups: es.comp.os.linux.programacion Subject: Re: Herencia en C :-) Date: 31 Mar 2002 14:39:16 -0800 Organization: http://groups.google.com/ Lines: 42 Message-ID: <4eb64fb0.0203311439.3b1c2191@posting.google.com> References: <8il77a.qj.ln@127.0.0.1> NNTP-Posting-Host: 217.127.113.184 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1017614356 6687 127.0.0.1 (31 Mar 2002 22:39:16 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 31 Mar 2002 22:39:16 GMT