C's
structs allow you to define a variable type in which you can hold a variety of elements by name ... and that's very similar to how you define all the variables within a C++
class. In a C++ class, though, you also define your methods which take that language forward into the Object Oriented world.
C's
unions let you define a block of memory which has two (or more) names associated with it so that - when combined with structs - you can produce a whole family of defined variable types based on a common core, but then varying in parts where appropriate. In OO terms, that's starting to head towards C++'s inheritance and polymorphism ...
(written 2008-03-13 18:28:44)
Associated topics are indexed under
C209 - C and C based languages - Structures and Unions [2573] C Structs - what, how and why - (2010-01-13)
[1669] What are Unions (C programming) - (2008-06-08)
[1584] Using Structs and Unions together effectively in C - (2008-03-21)
[1478] Some new C programming examples - files, structs, unions etc - (2007-12-19)
C233 - C and C based languages - OO in C++ - beyond the basics [2577] Complete teaching example - C++, inheritance, polymorphism - (2010-01-15)
[1819] Calling base class constructors - (2008-10-03)
[1674] What a lot of files! (C++ / Polymorphism demo) - (2008-06-12)
[1217] What are factory and singleton classes? - (2007-06-04)
[925] C++ - just beyond the basics. More you can do - (2006-11-14)
[831] Comparison of Object Oriented Philosophy - Python, Java, C++, Perl - (2006-08-13)
[801] Simple polymorphism example - C++ - (2006-07-14)
[798] References and Pointers in C++ - (2006-07-10)
Some other Articles
Making PHP and MySQL training relevant to the course delegatesDatabase design for a shopping application (MySQL)Joining MySQL tables revisited - finding nonmatching records, etcBudget tax increases hit vehicle marketC - structs and unions, C++ classes and polymorphismAwait guests in the early hoursLondon Midland ... Merrymaker ... Percy DanksI dont care - goodbyeWhat colour is the season?Melksham - Swindon. Train v Bus v Car