[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: casting an 'int' to a class
From: Andrew Sutton <ansutton () sep ! com>
Date: 2002-01-22 14:49:47
[Download RAW message or body]
On Monday 21 January 2002 10:30 pm, Ellis Whitehead wrote:
> > 1) remove the &
> > 2) I *think* some platforms (sparc64?) have sizeof(int) != sizeof(void*)
> >
> > Of course, if sizeof(int) and sizeof(void*) were the same, and the
> > variable is private, you should be able to just change the type.
>
> I don't really follow you... What's this about a void*? I'm not wanting
> to point to anything, but rather use an 'int' as though it were a
> particular class which contains a single 'int' member.
as far as my experience goes, all pointers are treated the same. it's just a
pointer. you can cast it to whatever you want.
> So if I say:
> int b = 123;
> cout << ((A*)&b)->a << endl;
> it prints 123.
i don't really think i've understood this whole thread. why would you need to
cast the address of an integer into a class pointer to call a function that
returns a reflexive value of the original integer. why not just use the
integer to begin with? besides there are tons of ways to solve this
legitimately.
andrew sutton
ansutton@sep.com
>> 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