<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Zero Intellect &#187; structure</title>
	<atom:link href="http://www.zerointellect.com/tag/structure/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zerointellect.com</link>
	<description>Technology Blog requiring Zero Intellect to follow !!!</description>
	<lastBuildDate>Mon, 28 Jun 2010 14:09:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Overview of a structure in C and C++</title>
		<link>http://www.zerointellect.com/programming/overview-of-a-structure-in-c-and-c/</link>
		<comments>http://www.zerointellect.com/programming/overview-of-a-structure-in-c-and-c/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 05:03:37 +0000</pubDate>
		<dc:creator>zrydento</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[data type]]></category>
		<category><![CDATA[record data fields]]></category>
		<category><![CDATA[record selector]]></category>
		<category><![CDATA[struct]]></category>
		<category><![CDATA[struct type name]]></category>
		<category><![CDATA[structure]]></category>
		<category><![CDATA[structure variable]]></category>
		<category><![CDATA[variable name]]></category>

		<guid isPermaLink="false">http://www.zerointellect.com/?p=254</guid>
		<description><![CDATA[<p> </p>
<p>The following article gives a brief overview of the structure in C/C++. The structure was first introduced in C where the need to group variables into a single record arose. Variables normally were assigned a single value or were assigned multiple values of the same type (array). The introduction of the structure allowed for variables to <p>Continue reading <a href="http://www.zerointellect.com/programming/overview-of-a-structure-in-c-and-c/">Overview of a structure in C and C++</a></p>]]></description>
			<content:encoded><![CDATA[<p> </p>
<p>The following article gives a brief overview of the structure in C/C++. The structure was first introduced in C where the need to group variables into a single record arose. Variables normally were assigned a single value or were assigned multiple values of the same type (array). The introduction of the structure allowed for variables to contain records of multiple values of different types. A simple comparison is displayed in the figure below</p>
<p><img class="aligncenter" src="http://www.zerointellect.com/uploads/05122009-diagram-1-1.png" alt="" width="350" height="375" /></p>
<p>A structure is of the format below and consists of 3 major components</p>
<p>1. struct-type-name<br />
2. structure-variable<br />
3. record data fields (data type, variable-name)</p>
<p> </p>
<blockquote><p>struct [<strong>&lt;struct-type-name&gt;</strong>]<br />
{<br />
 [<strong>&lt;type&gt;</strong> <strong>&lt;variable-names&gt;</strong>];<br />
 [<strong>&lt;type&gt;</strong> <strong>&lt;variable-names&gt;</strong>];<br />
 [<strong>&lt;type&gt;</strong> <strong>&lt;variable-names&gt;</strong>];<br />
 &#8230;<br />
}[<strong>&lt;structure-variables&gt;</strong>];</p></blockquote>
<p>The &lt;struct-type-name&gt; is an optional tag name that refers to the structure type. It should be defined to give a reflection of the contents of the structure. Such as &#8216;student&#8217; to indicate a record of student details. The &lt;structure-variables&gt; are the data definitions, and are also optional.</p>
<p>Though both are optional, one of the two must appear (makes logical sense, otherwise we would not be able to retrieve or store any values in the records). Elements in the record are defined by naming a &lt;type&gt;, followed by &lt;variable-names&gt; separated by commas. Different variable types can be separated by a semicolon.</p>
<p>A sample program follows that has a single record structure-variable as well as a structure-variable that holds 2 records</p>
<p> </p>
<p><strong># include &lt;iostream.h&gt;<br />
# include &lt;conio.h&gt;</strong></p>
<p><strong>void main()<br />
{<br />
 clrscr();</strong></p>
<p><strong> struct contact<br />
 {<br />
  char name[20];<br />
  int age;<br />
 }mrx;</strong></p>
<p><strong> cout&lt;&lt;&#8221;Name: &#8220;;<br />
 cin&gt;&gt;mrx.name;<br />
 cout&lt;&lt;&#8221;Age: &#8220;;<br />
 cin&gt;&gt;mrx.age;<br />
 cout&lt;&lt;&#8221;\nmrx.name : &#8220;&lt;&lt;mrx.name&lt;&lt;&#8221;\nmrx.age : &#8220;&lt;&lt;mrx.age;</strong></p>
<p><strong> struct contact family[2];</strong></p>
<p><strong> cout&lt;&lt;&#8221;\n\nEnter details of Family Members&#8230;\n&#8221;;</strong></p>
<p><strong> for(int i=0;i&lt;2;i++)<br />
 {<br />
  cout&lt;&lt;&#8221;\nName: &#8220;;<br />
  cin&gt;&gt;family[i].name;<br />
  cout&lt;&lt;&#8221;Age: &#8220;;<br />
  cin&gt;&gt;family[i].age;<br />
 }</strong></p>
<p><strong> cout&lt;&lt;&#8221;\nDetails of Family Members&#8230;&#8221;;</strong></p>
<p><strong> for(i=0;i&lt;2;i++)<br />
 {<br />
  cout&lt;&lt;&#8221;\n\nName :\t&#8221;&lt;&lt;family[i].name&lt;&lt;&#8221;\nAge :\t&#8221;&lt;&lt;family[i].age;<br />
 } <br />
      <br />
 getch();<br />
}</strong></p>
<p> </p>
<p>To access elements in a structure, you use a record selector (.)</p>
<p>For example, as it is mentioned in the program above mrx.age</p>
<p>To declare additional variables of the same type, you use the keyword struct followed by the &lt;struct-type-name&gt;, followed by the variable names</p>
<p>For example, the following declaration will create a record of 5 rows containing colleague details (age, name) as per our example program above</p>
<p><strong>struct colleagues[5];</strong></p>
<p>To summarize, structures were created to hold records of different data type values. But in C++ which is an object oriented language, classes were introduced that have many more benefits than structures. However, for simple implementations structures are very useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zerointellect.com/programming/overview-of-a-structure-in-c-and-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Types of Data Objects in C++</title>
		<link>http://www.zerointellect.com/programming/types-of-data-objects-in-c/</link>
		<comments>http://www.zerointellect.com/programming/types-of-data-objects-in-c/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 09:16:06 +0000</pubDate>
		<dc:creator>zrydento</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[aggregate]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[data objects]]></category>
		<category><![CDATA[fundamental]]></category>
		<category><![CDATA[scalar]]></category>
		<category><![CDATA[structure]]></category>
		<category><![CDATA[typedef]]></category>
		<category><![CDATA[user defined]]></category>

		<guid isPermaLink="false">http://www.zerointellect.com/?p=100</guid>
		<description><![CDATA[<p> </p>
<p>A data object is a block in computer memory that can either contain a single value of a group of values. The value of the data objects can be accessed using a simple variable or another complex expression. Each object has a unique data type which determines how much storage would be allocated in memory. It <p>Continue reading <a href="http://www.zerointellect.com/programming/types-of-data-objects-in-c/">Types of Data Objects in C++</a></p>]]></description>
			<content:encoded><![CDATA[<p> </p>
<p>A data object is a block in computer memory that can either contain a single value of a group of values. The value of the data objects can be accessed using a simple variable or another complex expression. Each object has a unique data type which determines how much storage would be allocated in memory. It is also used in any type checking operations. Both the identifier and data type of an object are established in the object declaration.</p>
<p>Suppose we declare an instance S1 of a class named Student that has variables name, age, class and other similar variables</p>
<blockquote><p><strong>Instance (S1 above) is known as the &#8220;class object&#8221;</strong></p>
<p><strong>Members of the class (age, name, etc) are also called &#8220;member objects&#8221;</strong></p></blockquote>
<p>The collection of all member objects within a class is what constitutes a class object</p>
<p> </p>
<p>There are three major classes of data types</p>
<blockquote><p><strong>Fundamental types vs derived types<br />
Built-in types vs user-defined types<br />
Scalar types vs aggregate types</strong></p></blockquote>
<p><strong> </strong></p>
<p>Fundamental data types are the ones that are &#8220;built-in&#8221; to the language. These already exist and are not created by the user. Examples are integers, floating-point numbers and characters. Derived data types are created from the set of basic types and include arrays, pointers, structures, classes, unions, and enumerations<br />
Built-in data types as made out by their name are those data types that are present and include all of the fundamental types and also include data types that refer to the addresses of basic types, such as arrays and pointers. User-defined types are created by the user from the set of basic types, in typedef, structure, classes, union, and enumeration definitions</p>
<p>Scalar types represent a single data value (like an integer) whereas aggregate types represent multiple values, of the same type or of different types. Scalars data types include the arithmetic types and pointers. Aggregate types include arrays, classes and structures</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zerointellect.com/programming/types-of-data-objects-in-c/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

