".rhavin grobert" <> wrote in news:1169841744.091698.6020
@s48g2000cws.googlegroups.com:
> Hi there
>
> I have the following struct:
>
> struct foo {
> union {
> unsigned __int64 ui64;
> char[8] c;
> };
> };
>
> what i now want to make possible is...
>
> foo a;
> foo b;
> int c;
> foo d;
> a = "abcdefg";
> b = 12;
> d = (foo) c;
>
> so i think i need to globally overload the cast operator, isn't it?
Why not assignment operators?
foo & foo:

perator=(__int64 newvalue)
{
ui64 = newvalue;
}
foo & foo:

perator=(const char * cp)
{
strncpy(c, cp, sizeof(c));
}
> i know how to overload the cast-operator to convert from my struct to
> $type, but how do i do it the other way 'round?
That would require you to overload operators on int.... can't be done.