Sun Nov 3 14:19:25 2024
EVENTS
 FREE
SOFTWARE
INSTITUTE

POLITICS
JOBS
MEMBERS'
CORNER

MAILING
LIST

NYLXS Mailing Lists and Archives
NYLXS Members have a lot to say and share but we don't keep many secrets. Join the Hangout Mailing List and say your peice.

DATE 2010-03-01

HANGOUT

2024-11-03 | 2024-10-03 | 2024-09-03 | 2024-08-03 | 2024-07-03 | 2024-06-03 | 2024-05-03 | 2024-04-03 | 2024-03-03 | 2024-02-03 | 2024-01-03 | 2023-12-03 | 2023-11-03 | 2023-10-03 | 2023-09-03 | 2023-08-03 | 2023-07-03 | 2023-06-03 | 2023-05-03 | 2023-04-03 | 2023-03-03 | 2023-02-03 | 2023-01-03 | 2022-12-03 | 2022-11-03 | 2022-10-03 | 2022-09-03 | 2022-08-03 | 2022-07-03 | 2022-06-03 | 2022-05-03 | 2022-04-03 | 2022-03-03 | 2022-02-03 | 2022-01-03 | 2021-12-03 | 2021-11-03 | 2021-10-03 | 2021-09-03 | 2021-08-03 | 2021-07-03 | 2021-06-03 | 2021-05-03 | 2021-04-03 | 2021-03-03 | 2021-02-03 | 2021-01-03 | 2020-12-03 | 2020-11-03 | 2020-10-03 | 2020-09-03 | 2020-08-03 | 2020-07-03 | 2020-06-03 | 2020-05-03 | 2020-04-03 | 2020-03-03 | 2020-02-03 | 2020-01-03 | 2019-12-03 | 2019-11-03 | 2019-10-03 | 2019-09-03 | 2019-08-03 | 2019-07-03 | 2019-06-03 | 2019-05-03 | 2019-04-03 | 2019-03-03 | 2019-02-03 | 2019-01-03 | 2018-12-03 | 2018-11-03 | 2018-10-03 | 2018-09-03 | 2018-08-03 | 2018-07-03 | 2018-06-03 | 2018-05-03 | 2018-04-03 | 2018-03-03 | 2018-02-03 | 2018-01-03 | 2017-12-03 | 2017-11-03 | 2017-10-03 | 2017-09-03 | 2017-08-03 | 2017-07-03 | 2017-06-03 | 2017-05-03 | 2017-04-03 | 2017-03-03 | 2017-02-03 | 2017-01-03 | 2016-12-03 | 2016-11-03 | 2016-10-03 | 2016-09-03 | 2016-08-03 | 2016-07-03 | 2016-06-03 | 2016-05-03 | 2016-04-03 | 2016-03-03 | 2016-02-03 | 2016-01-03 | 2015-12-03 | 2015-11-03 | 2015-10-03 | 2015-09-03 | 2015-08-03 | 2015-07-03 | 2015-06-03 | 2015-05-03 | 2015-04-03 | 2015-03-03 | 2015-02-03 | 2015-01-03 | 2014-12-03 | 2014-11-03 | 2014-10-03 | 2014-09-03 | 2014-08-03 | 2014-07-03 | 2014-06-03 | 2014-05-03 | 2014-04-03 | 2014-03-03 | 2014-02-03 | 2014-01-03 | 2013-12-03 | 2013-11-03 | 2013-10-03 | 2013-09-03 | 2013-08-03 | 2013-07-03 | 2013-06-03 | 2013-05-03 | 2013-04-03 | 2013-03-03 | 2013-02-03 | 2013-01-03 | 2012-12-03 | 2012-11-03 | 2012-10-03 | 2012-09-03 | 2012-08-03 | 2012-07-03 | 2012-06-03 | 2012-05-03 | 2012-04-03 | 2012-03-03 | 2012-02-03 | 2012-01-03 | 2011-12-03 | 2011-11-03 | 2011-10-03 | 2011-09-03 | 2011-08-03 | 2011-07-03 | 2011-06-03 | 2011-05-03 | 2011-04-03 | 2011-03-03 | 2011-02-03 | 2011-01-03 | 2010-12-03 | 2010-11-03 | 2010-10-03 | 2010-09-03 | 2010-08-03 | 2010-07-03 | 2010-06-03 | 2010-05-03 | 2010-04-03 | 2010-03-03 | 2010-02-03 | 2010-01-03 | 2009-12-03 | 2009-11-03 | 2009-10-03 | 2009-09-03 | 2009-08-03 | 2009-07-03 | 2009-06-03 | 2009-05-03 | 2009-04-03 | 2009-03-03 | 2009-02-03 | 2009-01-03 | 2008-12-03 | 2008-11-03 | 2008-10-03 | 2008-09-03 | 2008-08-03 | 2008-07-03 | 2008-06-03 | 2008-05-03 | 2008-04-03 | 2008-03-03 | 2008-02-03 | 2008-01-03 | 2007-12-03 | 2007-11-03 | 2007-10-03 | 2007-09-03 | 2007-08-03 | 2007-07-03 | 2007-06-03 | 2007-05-03 | 2007-04-03 | 2007-03-03 | 2007-02-03 | 2007-01-03 | 2006-12-03 | 2006-11-03 | 2006-10-03 | 2006-09-03 | 2006-08-03 | 2006-07-03 | 2006-06-03 | 2006-05-03 | 2006-04-03 | 2006-03-03 | 2006-02-03 | 2006-01-03 | 2005-12-03 | 2005-11-03 | 2005-10-03 | 2005-09-03 | 2005-08-03 | 2005-07-03 | 2005-06-03 | 2005-05-03 | 2005-04-03 | 2005-03-03 | 2005-02-03 | 2005-01-03 | 2004-12-03 | 2004-11-03 | 2004-10-03 | 2004-09-03 | 2004-08-03 | 2004-07-03 | 2004-06-03 | 2004-05-03 | 2004-04-03 | 2004-03-03 | 2004-02-03 | 2004-01-03 | 2003-12-03 | 2003-11-03 | 2003-10-03 | 2003-09-03 | 2003-08-03 | 2003-07-03 | 2003-06-03 | 2003-05-03 | 2003-04-03 | 2003-03-03 | 2003-02-03 | 2003-01-03 | 2002-12-03 | 2002-11-03 | 2002-10-03 | 2002-09-03 | 2002-08-03 | 2002-07-03 | 2002-06-03 | 2002-05-03 | 2002-04-03 | 2002-03-03 | 2002-02-03 | 2002-01-03 | 2001-12-03 | 2001-11-03 | 2001-10-03 | 2001-09-03 | 2001-08-03 | 2001-07-03 | 2001-06-03 | 2001-05-03 | 2001-04-03 | 2001-03-03 | 2001-02-03 | 2001-01-03 | 2000-12-03 | 2000-11-03 | 2000-10-03 | 2000-09-03 | 2000-08-03 | 2000-07-03 | 2000-06-03 | 2000-05-03 | 2000-04-03 | 2000-03-03 | 2000-02-03 | 2000-01-03 | 1999-12-03

Key: Value:

Key: Value:

MESSAGE
DATE 2010-03-09
FROM Ruben Safir
SUBJECT Subject: [NYLXS - HANGOUT] C++ Workshop _ Syntax Basics Structs Unions and
-------------------------------------------------------

Now - I've reached a crossroads about what direction I want to continue
in. I have a binary choice in front of me, left or right. So I decided
to split this down the middle. There are two other aggregate data
types, similar to structs, which create new data types when used, one is
the "union" and the other is the "class". The problem is, and this is
also true of struct in C++, that they are actually very complicated and
the class data construction is particularly important and lays out the
basis for most advanced C++ object oriented coding. But before I get
into a full throttle discussion of classes (and unions), I want to
discuss more elementry syntax uses, such as functions, a detailed look
at operators, typing syntax and flow control. But I want to be
complete.

I've been trying to underscore the point that everything in programming
is data. The code you write is data, variables are data, functions are
data, and literal data types are data. Data can be stored in C++ in
typed variable, anonymous memory segments pointed at by pointers, and
referred to through references. structs allow us to keep a lot of data
together in a single package (or object) that we can carry around as
needed. And although I haven't demonstrated this for structs, one of
the types of data that can be packaged in the data type includes
functions. This is true for unions, an is essential for classes.
Classes, Structs and Unions are really all related. But I don't want to
detail the correct constructions of Classes and Unions yet. So I'm
presenting a very simplified view of these data constructions, and later
we will greatly expand on them.

Unions:

Unions are inherited from C and they are often described as being
similar to structs. I'd like to turn this upside down and say that
Unions are really nothing like structs. They do share similar syntax,
but under the hood they are completely different.

A struct has many members that are packaged together sequentially. They
sit in memory likes duck on the pond. With union's we have one member
in memory, that can morph to any type that is defined within the
construction.

Union's are created similarly as struct's Their basic format is

union {
member;
member;
member;
} union_object, union_object;

Again, notice the semicolon at the end of the definition.

Here is a simple example:


union one_at_a_time{
int dataone;
int matrix[10];
double dollars1;
long double parts_per_billion;
};


one_at_a_time myunion; //declare a union of type one_at_a_time

union access is similar to a struct:

myunion1.dataone = 500;

cout << myunion1.dataone <

There is only one, however, data member for myunion. But it can be
accessed by any of the members names, which will most likely give you a
wrong result. We gave it an integer and if we try to retrive the data
as the double (using memeber dollar), we're going to get the binary data
for the int 500 intepreted as a double. The size of myunion is the size
of the largest data member of the union, in our case the int array
matrix. Here is an example of a union and the pitfalls:

#include
using namespace std;


int main(int argc, char * argv[]){


union one_at_a_time{
int dataone;
int matrix[10];
double dollars1;
long double parts_per_billion;
};


one_at_a_time myunion1;
myunion1.dataone = 500;

cout << myunion1.dataone <
//one_at_a_time myunion2;
//myunion2.matrix= { ,{6,5,4,3,2,1}}; doesn't work
//one_at_a_time myunion2= {6,5,4,3,2,1}; doest work ... you can only
//initialize with ONE data at a time

one_at_a_time myunion2;
myunion2.matrix[0] = 6;
myunion2.matrix[1] = 5;
myunion2.matrix[2] = 4;
myunion2.matrix[3] = 3;
myunion2.matrix[4] = 2;
myunion2.matrix[5] = 1;
myunion2.matrix[6] = 10;

for(unsigned int i = 0; i < sizeof(myunion2.matrix)/sizeof(int);
i++){
cout << myunion2.matrix[i] << endl;
}

myunion2.dollars1 = 2.75;

for(unsigned int i = 0; i < sizeof(myunion2)/sizeof(int); i++){
cout << "Dollar1==>" << myunion2.dollars1 << endl;
cout << "martix ==>" << myunion2.matrix[i] << endl;
}
}

--
http://www.mrbrklyn.com - Interesting Stuff
http://www.nylxs.com - Leadership Development in Free Software

So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998

http://fairuse.nylxs.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002

"Yeah - I write Free Software...so SUE ME"

"The tremendous problem we face is that we are becoming sharecroppers to our own cultural heritage -- we need the ability to participate in our own society."

"> I'm an engineer. I choose the best tool for the job, politics be damned.<
You must be a stupid engineer then, because politcs and technology have been attached at the hip since the 1st dynasty in Ancient Egypt. I guess you missed that one."

? Copyright for the Digital Millennium

  1. 2010-03-01 Paul Robert Marino <prmarino1-at-gmail.com> Re: [NYLXS - HANGOUT] this should not get through
  2. 2010-03-01 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Catching the streams from Flash Video
  3. 2010-03-02 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] [ruben-at-mrbrklyn.com: [jim-at-well.com: [conspire] open source
  4. 2010-03-02 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Phone Tech Wars
  5. 2010-03-02 Ron Guerin <ron-at-vnetworx.net> Subject: [NYLXS - HANGOUT] NYLUG Workshop / Hacking Society (Smalltalk, C++, Python) Tuesday March 2 6:00PM-8:00PM
  6. 2010-03-02 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] this should not get through
  7. 2010-03-02 Paul Robert Marino <prmarino1-at-gmail.com> Re: [NYLXS - HANGOUT] this should not get through
  8. 2010-03-02 Paul Robert Marino <prmarino1-at-gmail.com> Re: [NYLXS - HANGOUT] this should not get through
  9. 2010-03-03 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] C++ Workshop _ Syntax Basics - agregate data types
  10. 2010-03-03 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] C++ Workshop _ Syntax Basics - agregate data
  11. 2010-03-03 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] C++ Workshop _ Syntax Basics - agregate data
  12. 2010-03-04 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] C++ Workshop _ Syntax Basics
  13. 2010-03-05 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] C++ Workshop _ Syntax Basics
  14. 2010-03-05 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] AlphaOne Labs invited you to the event "Ask-a-Sysadmin
  15. 2010-03-06 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Professors Open Source Summer Experience -at-RIT
  16. 2010-03-07 Kevin Mark <kevin.mark-at-verizon.net> Re: [NYLXS - HANGOUT] Professors Open Source Summer Experience -at-RIT
  17. 2010-03-09 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] C++ Workshop _ Syntax Basics Structs Unions and
  18. 2010-03-09 From: "Beau Gould" <bg-at-capitalmarketsp.com> Subject: [NYLXS - HANGOUT] [JOB] System Administrator, NYC to 90k
  19. 2010-03-09 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] [JOB] System Administrator, NYC to 90k
  20. 2010-03-10 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] C++ Workshop _ Syntax Basics Structs Unions
  21. 2010-03-13 redpill <redpill-at-rcn.com> Subject: [NYLXS - HANGOUT] NYLXS Library?
  22. 2010-03-13 redpill <redpill-at-rcn.com> Subject: [NYLXS - HANGOUT] NYLXS Library?
  23. 2010-03-14 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] NYLXS Library?
  24. 2010-03-14 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] NYLXS Library?
  25. 2010-03-15 redpill <redpill-at-rcn.com> Re: [NYLXS - HANGOUT] NYLXS Library?
  26. 2010-03-15 redpill <redpill-at-rcn.com> Re: [NYLXS - HANGOUT] NYLXS Library?
  27. 2010-03-15 Contrarian <adrba-at-nyct.net> Re: [NYLXS - HANGOUT] NYLXS Library?
  28. 2010-03-15 Contrarian <adrba-at-nyct.net> Re: [NYLXS - HANGOUT] NYLXS Library?
  29. 2010-03-15 Contrarian <adrba-at-nyct.net> Re: [NYLXS - HANGOUT] NYLXS Library?
  30. 2010-03-15 Contrarian <adrba-at-nyct.net> Re: [NYLXS - HANGOUT] NYLXS Library?
  31. 2010-03-15 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] NYLXS Library?
  32. 2010-03-15 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] NYLXS Library?
  33. 2010-03-15 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] NYLXS Library?
  34. 2010-03-16 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] C++ Workshop _ Syntax Basic: Flow Control Structures
  35. 2010-03-16 Ron Guerin <ron-at-vnetworx.net> Subject: [NYLXS - HANGOUT] NYLUG Workshop / Hacking Society (Smalltalk, C++, Python) Tuesday March 16 6:00PM-8:00PM
  36. 2010-03-16 redpill <redpill-at-rcn.com> Re: [NYLXS - HANGOUT] NYLXS Library?
  37. 2010-03-16 redpill <redpill-at-rcn.com> Re: [NYLXS - HANGOUT] NYLXS Library?
  38. 2010-03-17 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] C++ Workshop - Switches and Break
  39. 2010-03-17 einker <eminker-at-gmail.com> Subject: [NYLXS - HANGOUT] Revolution OS at Darress Theatre
  40. 2010-03-20 Ron Guerin <ron-at-vnetworx.net> Subject: [NYLXS - HANGOUT] Free Software Round Table TONIGHT at 10PM (live streaming)
  41. 2010-03-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] C++ Workshop - Syntax Basics -- functions
  42. 2010-03-21 Kevin Mark <kevin.mark-at-verizon.net> Re: [NYLXS - HANGOUT] C++ Workshop - Syntax Basics -- functions
  43. 2010-03-21 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] C++ Workshop - Syntax Basics -- functions
  44. 2010-03-21 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] C++ Workshop - Syntax Basics -- functions
  45. 2010-03-21 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] NYLXS Library?
  46. 2010-03-21 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] NYLXS Library?
  47. 2010-03-21 Kevin Mark <kevin.mark-at-verizon.net> Re: [NYLXS - HANGOUT] C++ Workshop - Syntax Basics -- functions
  48. 2010-03-21 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] C++ Workshop - Syntax Basics -- functions
  49. 2010-03-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Tina Gasperson commented on Darin Gasperson's status...
  50. 2010-03-21 redpill <redpill-at-rcn.com> Re: [NYLXS - HANGOUT] NYLXS Library?
  51. 2010-03-22 From: "Beau Gould" <bg-at-capitalmarketsp.com> Subject: [NYLXS - HANGOUT] [JOB] Systems Engineer, NYC | 90-100k
  52. 2010-03-23 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] NYLXS Library?
  53. 2010-03-24 einker <eminker-at-gmail.com> Subject: [NYLXS - HANGOUT] Free Software Award Winners Announced
  54. 2010-03-24 einker <eminker-at-gmail.com> Subject: [NYLXS - HANGOUT] Free Software Award Winners Announced
  55. 2010-03-25 redpill <redpill-at-rcn.com> Re: [NYLXS - HANGOUT] NYLXS Library?
  56. 2010-03-25 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] NYLXS Library?
  57. 2010-03-25 swd <sderrick-at-optonline.net> RE: [NYLXS - HANGOUT] NYLXS Library?
  58. 2010-03-30 Ron Guerin <ron-at-vnetworx.net> Subject: [NYLXS - HANGOUT] NYLUG Workshop / Hacking Society (Smalltalk, C++, Python) Tuesday March 30 6:00PM-8:00PM

NYLXS are Do'ers and the first step of Doing is Joining! Join NYLXS and make a difference in your community today!