<?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>Technical Difficulties &#187; c</title>
	<atom:link href="http://greensoftware.net/blog/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://greensoftware.net/blog</link>
	<description>Solving my problems</description>
	<lastBuildDate>Thu, 01 Jul 2010 16:46:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>One good thing in Objective-C</title>
		<link>http://greensoftware.net/blog/2010/02/21/one-good-thing-in-objective-c/</link>
		<comments>http://greensoftware.net/blog/2010/02/21/one-good-thing-in-objective-c/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 12:24:15 +0000</pubDate>
		<dc:creator>digitalSurgeon</dc:creator>
				<category><![CDATA[c]]></category>
		<category><![CDATA[objective c]]></category>
		<category><![CDATA[annoyance]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://greensoftware.net/blog/?p=248</guid>
		<description><![CDATA[While learning about objective-c. I came across a single feature of objective-c which I think if moved to c++ would make for a lot less coding. Consider this objective c code for a class declaration: // .h file: @interface classname { // instance variables } +(void)classMethod; @end // .m file: @implementation classname -privateFunction1{} -classMethod { [...]]]></description>
			<content:encoded><![CDATA[<p>While learning about objective-c. I came across a single feature of objective-c which I think if moved to c++ would make for a lot less coding.</p>
<p>Consider this objective c code for a class declaration:<br />
<code><br />
// .h file:<br />
@interface classname  {<br />
    // instance variables<br />
}<br />
+(void)classMethod;<br />
@end</p>
<p>// .m file:<br />
@implementation classname<br />
-privateFunction1{}<br />
-classMethod { [self privateFunction1]; }<br />
@end<br />
</code></p>
<p>While if you would have to do something similar in c++, this is how you would do it:</p>
<p><code><br />
// .h file:<br />
class classname<br />
{<br />
public:<br />
void classMethod();</p>
<p>private:<br />
void privateFunction();<br />
}</p>
<p>// .cpp file:</p>
<p>void classname::classMethod()  { privateFunction(); }<br />
void classname::privateFunction()  {}</p>
<p></code></p>
<p>Even if a function in a C++ class is private, you still have to declare it in the class declaration. why ?<br />
It would be so much better if all the private functions can just placed in the cpp file, and we dont have to put them in the class declaration.</p>
<p>Objective C has the benefit of using @implementation &#8230; @end to figure out such methods. But if in c++ if we just declare a function in the .cpp file and such function is not present in the class declaration, the compiler can know that its a private function. Like so:</p>
<p><code><br />
// .h file:</p>
<p>class sample<br />
{<br />
public:<br />
 void doSomething();</p>
<p>private:<br />
int x;<br />
};</p>
<p>// .cpp file:</p>
<p>void sample::doSomethingPrivately()<br />
{<br />
// has access to member data.<br />
x = 7;<br />
}</p>
<p>void sample::doSomething()<br />
{<br />
 /// ...<br />
doSomethingPrivately();<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://greensoftware.net/blog/2010/02/21/one-good-thing-in-objective-c/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>c++ std::string</title>
		<link>http://greensoftware.net/blog/2009/07/10/c-stdstring/</link>
		<comments>http://greensoftware.net/blog/2009/07/10/c-stdstring/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 18:28:30 +0000</pubDate>
		<dc:creator>digitalSurgeon</dc:creator>
				<category><![CDATA[c]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[std::string]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://greensoftware.net/blog/?p=192</guid>
		<description><![CDATA[the c++ string or more specifically std::string is a great improvement over the c-strings which are null terminated. c++ strings use a length fields to keep track of how long the string is as compared to c-string which use the NULL &#8216;\0&#8242; character to keep track of where the string ends. The c-strings have been [...]]]></description>
			<content:encoded><![CDATA[<p>the c++ string or more specifically std::string is a great improvement over the c-strings which are null terminated. c++ strings use a length fields to keep track of how long the string is as compared to c-string which use the NULL &#8216;\0&#8242; character to keep track of where the string ends.</p>
<p>The c-strings have been around for so long and are used in so many places that when people start to use the std::string they get confused. For example today i wanted to use std::string to hold binary data, i knew that this was possible but i couldn&#8217;t figure out how. Then <a href="http://stackoverflow.com/questions/164168/how-do-you-construct-a-stdstring-with-an-embedded-null">stack overflow came to the rescue</a>. This question is explained very well there.</p>
<p>Thanks Stack Overflow <img src='http://greensoftware.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://greensoftware.net/blog/2009/07/10/c-stdstring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective-C Stupidities #1</title>
		<link>http://greensoftware.net/blog/2009/01/22/objective-c-stupidities-1/</link>
		<comments>http://greensoftware.net/blog/2009/01/22/objective-c-stupidities-1/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 15:30:48 +0000</pubDate>
		<dc:creator>digitalSurgeon</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[nextstep]]></category>
		<category><![CDATA[objective]]></category>
		<category><![CDATA[objective-c]]></category>

		<guid isPermaLink="false">http://greensoftware.net/blog/2009/01/22/objective-c-stupidities-1/</guid>
		<description><![CDATA[-(int)changeColorToRed:(float)red green:(float)green blue:(float)blue WTF ? Source: http://en.wikipedia.org/wiki/Objective-C]]></description>
			<content:encoded><![CDATA[<p>-(int)changeColorToRed:(float)red green:(float)green blue:(float)blue</p>
<p>WTF ?</p>
<p>Source: http://en.wikipedia.org/wiki/Objective-C</p>
]]></content:encoded>
			<wfw:commentRss>http://greensoftware.net/blog/2009/01/22/objective-c-stupidities-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
