Fri Nov 22 00:06:41 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-22 | 2024-10-22 | 2024-09-22 | 2024-08-22 | 2024-07-22 | 2024-06-22 | 2024-05-22 | 2024-04-22 | 2024-03-22 | 2024-02-22 | 2024-01-22 | 2023-12-22 | 2023-11-22 | 2023-10-22 | 2023-09-22 | 2023-08-22 | 2023-07-22 | 2023-06-22 | 2023-05-22 | 2023-04-22 | 2023-03-22 | 2023-02-22 | 2023-01-22 | 2022-12-22 | 2022-11-22 | 2022-10-22 | 2022-09-22 | 2022-08-22 | 2022-07-22 | 2022-06-22 | 2022-05-22 | 2022-04-22 | 2022-03-22 | 2022-02-22 | 2022-01-22 | 2021-12-22 | 2021-11-22 | 2021-10-22 | 2021-09-22 | 2021-08-22 | 2021-07-22 | 2021-06-22 | 2021-05-22 | 2021-04-22 | 2021-03-22 | 2021-02-22 | 2021-01-22 | 2020-12-22 | 2020-11-22 | 2020-10-22 | 2020-09-22 | 2020-08-22 | 2020-07-22 | 2020-06-22 | 2020-05-22 | 2020-04-22 | 2020-03-22 | 2020-02-22 | 2020-01-22 | 2019-12-22 | 2019-11-22 | 2019-10-22 | 2019-09-22 | 2019-08-22 | 2019-07-22 | 2019-06-22 | 2019-05-22 | 2019-04-22 | 2019-03-22 | 2019-02-22 | 2019-01-22 | 2018-12-22 | 2018-11-22 | 2018-10-22 | 2018-09-22 | 2018-08-22 | 2018-07-22 | 2018-06-22 | 2018-05-22 | 2018-04-22 | 2018-03-22 | 2018-02-22 | 2018-01-22 | 2017-12-22 | 2017-11-22 | 2017-10-22 | 2017-09-22 | 2017-08-22 | 2017-07-22 | 2017-06-22 | 2017-05-22 | 2017-04-22 | 2017-03-22 | 2017-02-22 | 2017-01-22 | 2016-12-22 | 2016-11-22 | 2016-10-22 | 2016-09-22 | 2016-08-22 | 2016-07-22 | 2016-06-22 | 2016-05-22 | 2016-04-22 | 2016-03-22 | 2016-02-22 | 2016-01-22 | 2015-12-22 | 2015-11-22 | 2015-10-22 | 2015-09-22 | 2015-08-22 | 2015-07-22 | 2015-06-22 | 2015-05-22 | 2015-04-22 | 2015-03-22 | 2015-02-22 | 2015-01-22 | 2014-12-22 | 2014-11-22 | 2014-10-22 | 2014-09-22 | 2014-08-22 | 2014-07-22 | 2014-06-22 | 2014-05-22 | 2014-04-22 | 2014-03-22 | 2014-02-22 | 2014-01-22 | 2013-12-22 | 2013-11-22 | 2013-10-22 | 2013-09-22 | 2013-08-22 | 2013-07-22 | 2013-06-22 | 2013-05-22 | 2013-04-22 | 2013-03-22 | 2013-02-22 | 2013-01-22 | 2012-12-22 | 2012-11-22 | 2012-10-22 | 2012-09-22 | 2012-08-22 | 2012-07-22 | 2012-06-22 | 2012-05-22 | 2012-04-22 | 2012-03-22 | 2012-02-22 | 2012-01-22 | 2011-12-22 | 2011-11-22 | 2011-10-22 | 2011-09-22 | 2011-08-22 | 2011-07-22 | 2011-06-22 | 2011-05-22 | 2011-04-22 | 2011-03-22 | 2011-02-22 | 2011-01-22 | 2010-12-22 | 2010-11-22 | 2010-10-22 | 2010-09-22 | 2010-08-22 | 2010-07-22 | 2010-06-22 | 2010-05-22 | 2010-04-22 | 2010-03-22 | 2010-02-22 | 2010-01-22 | 2009-12-22 | 2009-11-22 | 2009-10-22 | 2009-09-22 | 2009-08-22 | 2009-07-22 | 2009-06-22 | 2009-05-22 | 2009-04-22 | 2009-03-22 | 2009-02-22 | 2009-01-22 | 2008-12-22 | 2008-11-22 | 2008-10-22 | 2008-09-22 | 2008-08-22 | 2008-07-22 | 2008-06-22 | 2008-05-22 | 2008-04-22 | 2008-03-22 | 2008-02-22 | 2008-01-22 | 2007-12-22 | 2007-11-22 | 2007-10-22 | 2007-09-22 | 2007-08-22 | 2007-07-22 | 2007-06-22 | 2007-05-22 | 2007-04-22 | 2007-03-22 | 2007-02-22 | 2007-01-22 | 2006-12-22 | 2006-11-22 | 2006-10-22 | 2006-09-22 | 2006-08-22 | 2006-07-22 | 2006-06-22 | 2006-05-22 | 2006-04-22 | 2006-03-22 | 2006-02-22 | 2006-01-22 | 2005-12-22 | 2005-11-22 | 2005-10-22 | 2005-09-22 | 2005-08-22 | 2005-07-22 | 2005-06-22 | 2005-05-22 | 2005-04-22 | 2005-03-22 | 2005-02-22 | 2005-01-22 | 2004-12-22 | 2004-11-22 | 2004-10-22 | 2004-09-22 | 2004-08-22 | 2004-07-22 | 2004-06-22 | 2004-05-22 | 2004-04-22 | 2004-03-22 | 2004-02-22 | 2004-01-22 | 2003-12-22 | 2003-11-22 | 2003-10-22 | 2003-09-22 | 2003-08-22 | 2003-07-22 | 2003-06-22 | 2003-05-22 | 2003-04-22 | 2003-03-22 | 2003-02-22 | 2003-01-22 | 2002-12-22 | 2002-11-22 | 2002-10-22 | 2002-09-22 | 2002-08-22 | 2002-07-22 | 2002-06-22 | 2002-05-22 | 2002-04-22 | 2002-03-22 | 2002-02-22 | 2002-01-22 | 2001-12-22 | 2001-11-22 | 2001-10-22 | 2001-09-22 | 2001-08-22 | 2001-07-22 | 2001-06-22 | 2001-05-22 | 2001-04-22 | 2001-03-22 | 2001-02-22 | 2001-01-22 | 2000-12-22 | 2000-11-22 | 2000-10-22 | 2000-09-22 | 2000-08-22 | 2000-07-22 | 2000-06-22 | 2000-05-22 | 2000-04-22 | 2000-03-22 | 2000-02-22 | 2000-01-22 | 1999-12-22

Key: Value:

Key: Value:

MESSAGE
DATE 2010-03-05
FROM Ruben Safir
SUBJECT Re: [NYLXS - HANGOUT] C++ Workshop _ Syntax Basics
The next agregate data type that C++ provides is structs and unions.
Structs and Unions have largely been superceded in C++ by Classes. They
are inherited from C and are designed as the key multi-type agregrate
data type that C uses to create related gruops of data, similar to what
a database can provide. Through coding algorithism, their importance
have grown far greater than just mear static records, but in this
section we will look only at their basic syntax and usage.

The real limitation to arrays is that data must be all of the same type.
structs create a new type which contain many of types with in. The
basic format of a struct is as follows:

Declaration:

stuct struct_type_name {
data type;
data tpye;
....
}[optional object name];

Notice the semicolon on the end of the struct declaration, which is
unusual and particular to struct's in that it is after the curley brace.

structs create a new user defined data type, and after their declaration
can be used as any other data type:

Example:

struct birds{
char species[30];
char gender[1];
char color[10];
int size_in_inches;
double weight;
char diet[30];
};

birds african_grey;
birds canary;

or you can make the instances with the declation:


struct birds{
char species[30];
char gender[1];
char color[10];
int size_in_inches;
double weight;
char diet[30];
} canary, african_grey;



Now it might be noted here an important diference between C and C++. In
C, you need the struct keyword to create instances of your struct's.

C EXAMPLE:

struct birds african_grey;
struct birds canary;

Otherwise, you need to use typedef in C

typedef birds parrot;
parrot african_grey, scarlet_macaw, conour, monk, bundie;

or even use typedef in the declaration:

typedef struct {
char species[30];
char gender[1];
char color[10];
int size_in_inches;
double weight;
char diet[30];
} birds;


birds african_grey;
birds canary;

This is a variation of typedef, which we haven't covered. In general
typedef creates an alias for a datatype of any kind:

typedef data_type alias;

typedef int BOOL;
typedef char[300] buffer;

thus the above example:
typedef struct {
char species[30];
char gender[1];
char color[10];
int size_in_inches;
double weight;
char diet[30];
} birds;

is not the same as
struct birds {
char species[30];
char gender[1];
char color[10];
int size_in_inches;
double weight;
char diet[30];
} canary, african_grey;


None creates a new data type, "birds" and the other creates new
instances of the struct, "canary", "african_grey".

****in C***

struct's can be initialized in C++ as follows, with the use of the assignment
operator and curly braces:

birds african_grey = { "African Grey Congo", 'M', "Light Grey", 13, 8.34, "Fruit and Seed" };
birds canary = { "Red Factor Canary", 'M', "Red to Orange", 2, 1.2, "Seed and Grass" };


in C remember to add the struct keyword.


The internal data types are reached by use of the dot operator.

char * color = canary.color;
cout << canary.color << endl;

strcpy(canary.color, "Deep Red"); //can not assign a char[]


You can make a pointer to a struct, and this is often useful

birds * canary;

but remember that you have no memory allocated for members yet.

birds *finches, parrot={"Conure", 'F', "Green", 6, 60, "Oranges and Peanuts"};

finches = &parrot;


When you use a pointer, access to members is gained using the infix
operaotr "->"

Example:

struct birds{
char species[30];
char gender[1];
char color[10];
int size_in_inches;
double weight;
char diet[30];
} *finches, parrots = {"Conure",'F',"Yellow",'6',60,"Peanuts and Oranges"};

finches = &parrots;

cout << "Your " << finches->species << "is " << finches->color << endl;


By creating arrays of struct's, large databases of records can be stored
in your program

birds finches[100];

strcpy(finches[0].species, "Zebra Finch");


birds *parrots[100];

strcpy(parrot[0]->species, "Amazon");


  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!