[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: casting an 'int' to a class
From: Nicolas Goutte <nicog () snafu ! de>
Date: 2002-01-22 20:09:22
[Download RAW message or body]
How about:
class A
{
public:
A(int i) {a=i;}
int x();
inline operator int(void) const {return a;}
private:
int a;
};
int foo()
{
A b(0);
return b.x();
}
Have a nice day/evening/night!
On Tuesday 22 January 2002 01:54, Ellis Whitehead wrote:
> Would the following cast from an int to a struct cause problems on any
> systems?
>
> struct A {
> int a;
> int x();
> };
>
> int foo() {
> int b = 0;
> return ((A*)(&b))->x();
> }
>
> I have a couple classes related to kdelibs/kdecore/kkey* that contain only
> a single 'int' of data. I would like to keep them private and put 'int's
> in the containing class definition.
>
> Thanks,
> Ellis
>
> >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to
> >> unsubscribe <<
>> 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