<?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>sparkymat &#187; c</title>
	<atom:link href="http://www.sparkymat.net/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sparkymat.net</link>
	<description></description>
	<lastBuildDate>Wed, 21 Dec 2011 17:09:00 +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>The Classy Struct</title>
		<link>http://www.sparkymat.net/2006/08/the-classy-struct/</link>
		<comments>http://www.sparkymat.net/2006/08/the-classy-struct/#comments</comments>
		<pubDate>Wed, 09 Aug 2006 03:12:20 +0000</pubDate>
		<dc:creator>sparkymat</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://blog.sparkymat.net/2006/08/08/the-classy-struct/</guid>
		<description><![CDATA[So what exactly is the difference between a class and a struct in C++? After wondering and debating internally for quite a long time, I looked around the net and found the (simple) explanation that: &#8220;The only difference between a struct and a class is in the default access.&#8221; That is, a sruct is public [...]]]></description>
			<content:encoded><![CDATA[<p>So what exactly is the difference between a <strong>class </strong>and a <strong>struct </strong>in C++? After wondering and debating internally for quite a long time, I looked around the net and found the (simple) explanation that:</p>
<p>&#8220;The only difference between a <strong>struct</strong> and a <strong>class</strong> is in the default access.&#8221;</p>
<p>That is, a <strong>sruct </strong>is public by default and a <strong>class </strong>is private by default. Extending (inheriting) them is also like-wise &#8211; public inheritance for <strong>struct </strong>and private for <strong>class</strong>.</p>
<p>I believe <strong>struct </strong>was made public by default to be compliant with C . Thus a C <strong>struct</strong> can be used similarly in C++. i.e.</p>
<p>[cpp]</p>
<p>struct Foo<br />
{<br />
int bar;<br />
char* baz;<br />
};</p>
<p>Foo makeFoo()<br />
{<br />
Foo temp;<br />
temp.bar = 1;<br />
temp.baz = &#8220;test&#8221;;<br />
return temp;<br />
}</p>
<p>[/cpp]</p>
<p>The only reason the above code will work in C++ is because of the default access of <strong>struct </strong>being public.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sparkymat.net/2006/08/the-classy-struct/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

