Unions

Started by
11 comments, last by masonium 22 years, 6 months ago
Unions also have another BIG role in almost all of Microsoft''s new technologies.

In the COM world, the VARIANT data type is a giant union!! Cool, isn''t it That''s why it can store all those different data types.

-nt20
Advertisement
I''ve always known what unions were, but never what to do with them... The example of having both a float and an int in the same one gave me a great idea (probably not a new one). I always make horribly complicated classes for variables in my scripting language(s) that remember what type they are and behave accordingly. I could replace all that with a simple union! hehehe thx

--------------------


You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming

You are unique. Just like everybody else.

"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

--------------------

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

An alternative to the RGB macro...

  union RGB{   unsigned long composite;   struct   {         unsigned char r;         unsigned char g;         unsigned char b;   }}//..........RGB myColor;myColor.r = 82;myColor.g = 255;myColor.b = 9;if(myColor.composite == RGB(82, 255, 9)){    //This code WILL execute...}  

This topic is closed to new replies.

Advertisement