Re: GdkColor weird type? Why not pointer like GtkWidget*....
- From: Daniel Elstner <daniel elstner gmx net>
- To: rsteinke w-link net
- Cc: seberino spawar navy mil, gtk-list gnome org
- Subject: Re: GdkColor weird type? Why not pointer like GtkWidget*....
- Date: 22 Apr 2002 21:36:29 +0200
Am Mon, 2002-04-22 um 21.22 schrieb rsteinke w-link net:
> From: Christian Seberino <seberino spawar navy mil>
> >
> > Thanks so much for this reply! I was really confused
> > about this! Can I ask you a follow up question?
> >
> > Just to make GdkColor be like everything else (a pointer)
> > is it OK to try declaring all colors to be pointer (GdkColor*) types???
Since when is everything else a pointer? Don't use pointers if you
don't have to.
> > Then instead of:
> > Colors::myStaticColor.red = 343;
> >
> > I could hopefully do:
> > (*Colors::myStaticColor).red = 343;
> >
> > or even better, Colors::myStaticColor->red = 343;
> >
> > Hopefully I can then initialize things to make them look more like a class:
> >
> > GdkColor* Colors::myStaticColor = (GdkColor*) 0;
You're confusing something. A class can be created on stack, as well as
allocated in free storage / heap.
> This'll get you a nice seg fault.
>
> You're declaring a pointer, but not allocating any memory.
Yes. And there's no reason to make your life harder just for the sake
of having a pointer.
> > Is there any reason this fantasy should not work??? I tried last nite
> > and got seg faults so I don't know if this is not doable or I just
> > made a dumb mistake. As you said, GdkColor is a "extern C struc". I'm not
> > a "extern C struc" expert. :(
Forget that rubbish. There's no 'extern "C" struct'. extern "C" does
nothing but specify the C linkage convention for functions -- don't
worry if you don't understand this yet.
> Go look at any basic C language reference (not C++).
Any good C++ book will help you as well. C++ is mostly compatible to C,
except for some obscure features that are deprecated in C too. If it
weren't compatible, you wouldn't even be able to include GTK+ headers in
your program.
--Daniel
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]