[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: casting an 'int' to a class
From: Simon Hausmann <hausmann () kde ! org>
Date: 2002-01-22 7:17:58
[Download RAW message or body]
On Tue, Jan 22, 2002 at 12:28:43AM -0500, Ellis Whitehead wrote:
> > I don't think the obfuscation is worth the gains (if there are any).
>
> Without:
> A a(b);
> a->transform( c );
> b = a->a;
> With casting:
> ((A*)&b)->transform( c );
>
> Without casting requires wierd code or a non-OO API. I wrote the non-OO API
> first, and decided that it was too convoluted. Then I did the OO without
> casting, and decided it was too long and ugly. Also, an inline function is
> used for the casting which pretties up the appearance, so the above code is
> just to show the principle.
Without:
b = A( b ).transform( c );
Or rather: don't store b as int in the first place.
Accessing the stored integer value:
A bleh = ...
int foo = bleh; // use operator int () const { return value; }
I agree with Waldo. Such hacks aren't worth it IMHO, and the
original syntactical problem can be solved easily.
Simon
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic