2 Replies - 11185 Views - Last Post: 17 January 2013 - 04:31 PM Rate Topic: -----

#1 latined52  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 22-December 12

C++ Unions

Posted 17 January 2013 - 12:42 PM

This week in C++ Intro class we are discussing unions.
I do not understand why this concept is still discussed.
With (most) computers having sufficient amount of RAM available aren't unions obsolete?

I have almost no programming knowledge, so please let me know if my thinking is wrong.

Thanks
Is This A Good Question/Topic? 0
  • +

Replies To: C++ Unions

#2 Ticon  Icon User is offline

  • D.I.C Regular

Reputation: 28
  • View blog
  • Posts: 320
  • Joined: 20-August 09

Re: C++ Unions

Posted 17 January 2013 - 04:16 PM

It can be helpful when dealing with microprocessors where you have very little space.

edit: also alot of legacy things are still discussed. Just because they are old doesn't mean you shouldn't know about them :)

This post has been edited by Ticon: 17 January 2013 - 04:16 PM

Was This Post Helpful? 0
  • +
  • -

#3 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1148
  • View blog
  • Posts: 7,149
  • Joined: 07-September 06

Re: C++ Unions

Posted 17 January 2013 - 04:31 PM

Also, you have to remember that they are useful, if not in what you are programming quite possibly in something lower-level.

For instance, if you wanted to store an RGBA color as a single integer, but still be able to get each of the channels out quickly and easily, a union would do all the extra work for you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1