<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.brandon-rodriguez.com/index.php?action=history&amp;feed=atom&amp;title=Programming%2FStructs</id>
	<title>Programming/Structs - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.brandon-rodriguez.com/index.php?action=history&amp;feed=atom&amp;title=Programming%2FStructs"/>
	<link rel="alternate" type="text/html" href="https://wiki.brandon-rodriguez.com/index.php?title=Programming/Structs&amp;action=history"/>
	<updated>2026-05-07T12:56:10Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.brandon-rodriguez.com/index.php?title=Programming/Structs&amp;diff=432&amp;oldid=prev</id>
		<title>Brodriguez: Brodriguez moved page Structs to Programming/Structs</title>
		<link rel="alternate" type="text/html" href="https://wiki.brandon-rodriguez.com/index.php?title=Programming/Structs&amp;diff=432&amp;oldid=prev"/>
		<updated>2020-10-25T17:26:02Z</updated>

		<summary type="html">&lt;p&gt;Brodriguez moved page &lt;a href=&quot;/Structs&quot; class=&quot;mw-redirect&quot; title=&quot;Structs&quot;&gt;Structs&lt;/a&gt; to &lt;a href=&quot;/Programming/Structs&quot; title=&quot;Programming/Structs&quot;&gt;Programming/Structs&lt;/a&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 17:26, 25 October 2020&lt;/td&gt;
				&lt;/tr&gt;
&lt;!-- diff cache key dev_wiki:diff::1.12:old-221:rev-432 --&gt;
&lt;/table&gt;</summary>
		<author><name>Brodriguez</name></author>
	</entry>
	<entry>
		<id>https://wiki.brandon-rodriguez.com/index.php?title=Programming/Structs&amp;diff=221&amp;oldid=prev</id>
		<title>Brodriguez: Create page</title>
		<link rel="alternate" type="text/html" href="https://wiki.brandon-rodriguez.com/index.php?title=Programming/Structs&amp;diff=221&amp;oldid=prev"/>
		<updated>2020-05-12T02:07:27Z</updated>

		<summary type="html">&lt;p&gt;Create page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The term &amp;quot;struct&amp;quot; stands for &amp;quot;structure&amp;quot;. Conceptually, it can be thought of as a grouping of variables.&lt;br /&gt;
&lt;br /&gt;
Alternatively, a struct can be though of as a [[Classes | class]] that has no constructor or [[Functions | methods]] associated with it.&lt;br /&gt;
&lt;br /&gt;
Note that some higher level languages, such as Java, don&amp;#039;t have support for Structs. In these instances, you can accomplish the same thing with a [[Classes | class]].&lt;br /&gt;
&lt;br /&gt;
== General Concept ==&lt;br /&gt;
Hypothetically, let&amp;#039;s say a business has a custom program. This program has a few &amp;quot;core&amp;quot; variables that are used throughout.&amp;lt;br&amp;gt;&lt;br /&gt;
We can call them {{ic | Revenue}}, {{ic | Expenses}}, and {{ic | Profit}}.&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s also suppose that, in this program, any time one of the above variables is uses, the rest are guaranteed to be used shortly after.&amp;lt;br&amp;gt;&lt;br /&gt;
Finally, let&amp;#039;s assume that we are avoiding use of global variables, to avoid cluttering namespace.&lt;br /&gt;
&lt;br /&gt;
One way to write this is to individually pass these three variables back and forth to all functions that need it:&lt;br /&gt;
 my_function(int revenue, int expenses, int profit) {&lt;br /&gt;
     ...&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
     return revenue, expenses, profit    &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
However, depending on how large the program is and how many functions it has, this can get repetitive and easy to mess up.&lt;br /&gt;
&lt;br /&gt;
Alternatively, it can be much cleaner to group these into a single object, aka a struct.&lt;br /&gt;
 struct costs {&lt;br /&gt;
     int revenue,&lt;br /&gt;
     int expenses,&lt;br /&gt;
     int profit,&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Then any time you need to reference these values, instead pass the struct that contains them:&lt;br /&gt;
 my_function(struct costs) {&lt;br /&gt;
     ...&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
     return costs;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
While this example is somewhat contrived, it shows how useful it can be to group variables together into a single object.&lt;/div&gt;</summary>
		<author><name>Brodriguez</name></author>
	</entry>
</feed>