|
|
Warp wrote:
> Darren New <dne### [at] sanrrcom> wrote:
>> Warp wrote:
>>> IntegerOrFloat* ptr = whatever;
>
>> That's a pointer to a struct. :-)
>
> A union is not a struct.
My bad. I understood, I just mispoke.
> The 'ptr' truely points directly to either an
> integer or a float,
No, it points to the union. The integer and the float are both at the
same *address*, but the pointer points to a *union*. :-)
Consider the difference between "pointer arithmetic" and "address
arithmetic". If ptr points to an integer, then ptr++ should change its
address by sizeof(int), right?
Again, it's nitpicking, but it's the kind of language-lawyering that
language designers babble about.
> at the exact same memory location. There's no need
> to calculate memory offsets.
Right. That's *address* arithmetic, tho. You can have different types of
pointers all pointing to the same address, *because* the difference
between "pointer" and "address" is whether it has a type. (At least in
most language design discussions.)
>> You can implement private methods that only the class can call and which
>> are invisible to any code not in the class defining the method, if
>> that's what you mean. You can even put it in a separate file all by itself.
>
> If that's so, what's this talk about C# forcing you to implement everything
> inline? I thought that meant you *can't* implement any part of a class in
> a separate file.
Err, no. It's called a "partial class". I believe perhaps the first
version of C# didn't have that?
// File A1.cs
partial class A {
void alpha(...) { ... }
}
// File A2.cs
partial class A {
void beta(...) { ... }
}
As I said, mostly used for code generators to stay out of your way.
--
Darren New / San Diego, CA, USA (PST)
"That's pretty. Where's that?"
"It's the Age of Channelwood."
"We should go there on vacation some time."
Post a reply to this message
|
|